QB64 Phoenix Edition
Tokenizer in QB64 - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3)
+---- Forum: Programs (https://staging.qb64phoenix.com/forumdisplay.php?fid=7)
+---- Thread: Tokenizer in QB64 (/showthread.php?tid=1502)

Pages: 1 2


RE: Tokenizer in QB64 - aurel - 02-25-2023

so my question is why QB64 don't recognize string variable defined As String
and know quoted "text"


RE: Tokenizer in QB64 - mnrvovrfc - 02-25-2023

(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.


RE: Tokenizer in QB64 - aurel - 02-25-2023

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.