-->
Page 1 of 2

Initial Variable Assignment Bug

PostPosted: Sat Aug 20, 2016 12:30 pm
by PhilTilson
Previous posts have noted that ALL variables appear to be assigned string status initially - but it's a bit more complicated than that!
Code: Select allx=27
y=27
if x=y then print "The same!" else print "Different!"
end

results in: "Comparaison between string and number!" on lines 2 and 3.

Code: Select allx=0
y=0
x=27
y=27
if x=y then print "The same!" else print "Different!"
end

gives the same error on lines 2, 4 and 5. However...

Code: Select allx = 27
y = 27
if x=y then print "The same!" else print "Different!"
end

results in "The same!" (ie the correct result)

According to the latest documentation,
Spaces are don’t care :

A = 5 + 3 is the same as a=5+3

Clearly this is not the case!

Phil

Re: Initial Variable Assignment Bug

PostPosted: Sat Aug 20, 2016 7:27 pm
by Mmiscool
Can you point out in the docs where it says the spaces don't matter?

For assignment of a value to variable you must have spaces around the = sign.

x = 0

x = 27

Re: Initial Variable Assignment Bug

PostPosted: Sun Aug 21, 2016 4:29 pm
by PhilTilson
The quote in my e-mail is from the last two lines in the section headed "SPECIFICITY OF THE NEW PARSER".

Phil

Re: Initial Variable Assignment Bug

PostPosted: Sat Aug 27, 2016 12:41 pm
by PhilTilson
I have now tested this point more carefully.

The only space that seems to matter is the one between the variable getting the value and the '=' sign. So:

Code: Select alla=1+2          will NOT work
a = 1 + 2      does work.  But...
a =1+2         also works!
print a&b&c    Also works fine

So it seems that the initial space is the only one that is essential, though including others may make for better layout and readability.

Phil