Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax and other suggestions
#11
Also

dim TagStr$ as string ' cause error

C:\BAS\RAPIDQ\RQSR_SRC\ver121\FBtestParseTag.bas(36) : error 18: Syntax error, found: 'as'

dim TagStr$ as string
^

Is it possible to eliminate this error message?

I know that in QB I need use
dim TagStr as string
or
dim TagStr$
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#12
Also

- inline string indexing as in "char = somestring[idx]" (V1c)

mm..
As I see char is not string type, it's byte.

TagStr$="123456789"
for i=1 to len(TagStr$)
print chr$(TagStr$[i-1])
print mid$(TagStr$,i,1)
next

I.e TagStr$[i] is not equ mid$(TagStr$,i,1) ?? Sad
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#13
INC/DEC is another n-ways-to-do-the-same-thing when you have I+=1, I-=1 already, most languages that have those need that to optimize I = I + 1, but FB will optimize that to INC I anyways.. and i used variables named INC in many of my old QB projects, name clashes will arise..

If string indexing returned another string there would be no reason for it exist. String allocation is a slow operation and string indexing was added to speed up string operations done in loops and to skip the pointer initialization with strptr() and so on.. But you can do if( s[i] = asc( "A" ) ), ASC() with constant strings is evaluated at compile-time, the speed will be the same as if( s[i] = 65 )..

Due the QB quirks i can't add suffix plus explicit type to declarations, you have to chose one or another, sorry.

IMO, the DEF### syntax is terrible, but it can be done as macros:

Code:
#define DEFSTR DIM AS STRING
    DEFSTR A, B, C

Because in FB you can do "DIM AS SomeType Symbol", plus the "old" way "DIM Symbol AS SomeType".
Reply
#14
Yes, thank you.
Really there are no big problems. Smile
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#15
What about string Subtraction operator?

ie. "jello"-"l"
is "jello" minus all occurrences of "l" = "jeo"
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply
#16
Code:
declare sub inc(byref x as integer,byval i as integer=1)
sub inc(byref x as integer,byval i as integer=1)
   x+=i
end sub

inc y
print y
inc y,11
print y
inc(y,11)
print y
sleep

better?
ttp://m0n573r.afraid.org/
Quote:quote: "<+whtiger> you... you don't know which way the earth spins?" ... see... stupidity leads to reverence, reverence to shakiness, shakiness to... the dark side
...phear
Reply
#17
Quote:What about string Subtraction operator?

ie. "jello"-"l"
is "jello" minus all occurrences of "l" = "jeo"

that's somthing a extend string lib should do and not somthing that should be in the runtime.

FB use the C philosophy on programming keep the Run time small and use lib's for everything. although fb support a bunch of string functions in the runtime which it has to too be compatible with Basic standers it still shouldn't be bloated/name space poluated with extra string functions which can be easy written by the programmer.
Reply
#18
Quote:
Code:
declare sub inc(byref x as integer,byval i as integer=1)
sub inc(byref x as integer,byval i as integer=1)
   x+=i
end sub
[...]

better?

Nice!
Thank you.
ith best regards, Andrew Shelkovenko.
http://www.wildgardenseed.com/RQDP/FreeBasic/index.html - FreeBasic documentation Project
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)