Tokenizer in QB64
#11
so my question is why QB64 don't recognize string variable defined As String
and know quoted "text"
Reply
#12
(02-25-2023, 03:43 PM)aurel Wrote: but why i get syntax error with simple function call here:

'call function tokenizer()

tokenizer(test)

If you have to call that you have to do something like this:

Code: (Select All)
dummy = tokenizer(test)

Because QB64(PE) isn't as lenient as Freebasic and other languages allowing a function call that "throws away" the result. M$ QuickBASIC design resisted being like C/C++ in allowing function results to be ignored as "side-effect", because in those other languages everything is a function, including the one called "main()" which has to be in every single program.

If you have to give a data type to a function at all, shouldn't that remind you that you need a variable of the same type for LHS, and that there should be a LHS? Otherwise declare that "function" as a SUB and leave out the "outer" parenthesis required for a function call. Like this:

Code: (Select All)
tokenizer test

It could look more confusing for somebody not used to programming this way, or he/she is used to other BASIC dialects.

(02-25-2023, 04:47 PM)aurel Wrote: and i do as string variable which is of course declared with Dim

'call function tokenizer()

tokenizer&(test)

but he called function using quoted string
like :
accept&("text")

You need a long integer variable on LHS and call it:

Code: (Select All)
DIM test AS STRING
dummy& = tokenizer(test)

or

Code: (Select All)
DIM dummy AS LONG, test AS STRING
dummy = tokenizer(test)

The "accept&()" is the same thing. Just replace "tokenizer" with "accept" in the examples above. Functions require LHS in QB64(PE). If this is not acceptable, and you don't want or need to declare another variable only to hold an "useless" function result you should redefine that "function" as a SUB.
Reply
#13
mnv

i know all what you saying but only don't know this:

Code: (Select All)
dummy = tokenizer(test)

so everything else is fine...not all compiler "think" that everything is a function , i used to use o2 and there is more strange
thing in o2 ..it is same SUB or FUNCTION both can return itself as variable value.
Reply




Users browsing this thread: 1 Guest(s)