LoginLogin
Might make SBS readonly: thread

[fixed] READ VAR() errors

Root / SmileBASIC Bug Reports / [.]

incvoidCreated:
12me21 showed me this READing into a variable reference returned by VAR() may crash, if the parameter passed to VAR( ) is the name of an array...it crashes I think(forgot the test), with non-arrays it starts acting funky
cls 'comment this out and see if it runs
OPTION STRICT
OPTION DEFINT
VAR A,S$ 'change A to A[1] for a hard crash
S$="A"
data 4
?A
read var(S$)'add [0] for the array hard crash
?A'comment this out and now see if there is enough data
gets funky when you replace ?A's with just ?'s blank lines no variables...its as if the console got corrupted or something..I wonder if its only console lines messing things up

Need a bug report? Here you go. This bug looks compile-time. The program never seems to actually run, at least how I was testing it. I also don't see what you mean about glitchy console. Care to elaborate/screenshot? I copied your code verbatim and got Internal Error in 0:8...hmm. There might be more to this. In my test, I suffixed my variables. It looks like VAR() might depend on suffix for type determination? Very weird.

Now, what I really want to know is, what is error #2? most likely another "Internal Error", or maybe it's unused...

Need a bug report? Here you go. This bug looks compile-time. The program never seems to actually run, at least how I was testing it. I also don't see what you mean about glitchy console. Care to elaborate/screenshot? I copied your code verbatim and got Internal Error in 0:8...hmm. There might be more to this. In my test, I suffixed my variables. It looks like VAR() might depend on suffix for type determination? Very weird.
as you comment out the ?A lines...you get different output... takes a few steps. run it once, it says internal error..comment out the cls, then you get out of data. comment the last ?A and it turns..bizarre. I was saying cls and ?/print are console commands. http://vid.me/hxPl

Maybe it's run out of data, so it starts reading from whatever it can find? That's strange, I don't have any idea why something like this would happen. Maybe internal error is when something gets corrupted during compilation so it can't run. Also strange... [cue music]

Maybe it's run out of data, so it starts reading from whatever it can find? That's strange, I don't have any idea why something like this would happen. Maybe internal error is when something gets corrupted during compilation so it can't run. Also strange... [cue music]
Maybe we can use READ to access memory too...

Maybe it's run out of data, so it starts reading from whatever it can find? That's strange, I don't have any idea why something like this would happen. Maybe internal error is when something gets corrupted during compilation so it can't run. Also strange... [cue music]
Maybe we can use READ to access memory too...
give it more data, more numbers and it seems to shift the data over..but not actual new data.. like DATA 4,3,2,1 ?A starts becoming 400 then 4003000 etc...type error after that. certainly not programatically cause the moment ya do cls or ? it changes what is being read etc... http://vid.me/1m39

So I saw the activity on this thread and I gave the code a little whirl.
VAR A,S$="A"
?A
DATA 4,7 'last DATA entry is arbitrary
READ VAR(S$)
?A
So, when you run it, you'll get 0 followed by some other seemingly random number displayed on the console. I found that if you go back and plug that other number back into the DATA line of code for the first DATA entry (in the above case, replacing 4 with the new number), well, you'll receive another 'random' number, but if you keep doing this, you'll eventually reach the number 262148. Every single number you enter (including 0, negative numbers, floating point numbers, anything constant-folded I assume) seems to eventually reach 262148. 262148 is (2^18)+4, FYI. Occasionally, when doing this glitch, the console will seem to stagger, and the keyboard will disappear for 1 frame.

Oh, does this still work? I must have made a mistake while testing.