Qbasicnews.com

Full Version: Syntax and other suggestions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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$
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
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".
Yes, thank you.
Really there are no big problems. Smile
What about string Subtraction operator?

ie. "jello"-"l"
is "jello" minus all occurrences of "l" = "jeo"
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?
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.
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.
Pages: 1 2