nathanielbabiak 2022-03-25 03:15 (Edited)
The following code works. Do you have any opinion on whether it should work, in the spirit of LowRes NX?
The manual doesn't indicate whether or not this is intended behavior. I don't want to use it if not.
SUB MIN_REPRO_EXAMPLE X = X END SUB
nathanielbabiak 2022-03-25 03:19 (Edited)
Or, reading the manual, maybe this is explicitly not intended behavior?
Variables are not explicitly declared, but they need to be initialized with a value before you can read from them. Values are assigned to variables using the equal symbol.
(FYI your system initializes that right-most X to zero and assigns it to the left-most X.)
was8bit 2022-03-25 04:54
I would assume that "variablename =" instantly flags "variablename" as assigned and therefore usable, so that once it comes to the second occurance "variablename" it's cleared as 'good to go, no error"
X=X+2 might be something someone might use... however,
ADD X,2 is flagged with an error...
Interstingly, DIM auto assigned zeros...
Works just fine, no errors ;)
Timo 2022-03-25 15:06
I didn’t check the code now, but I guess Was8bit is right, so the interpreter reads the line from left to right and so it already created the variable X.
I won’t fix it, but it’s not the intended behavior.
Why would you use X=X?
Timo 2022-03-25 15:08
On the other hand, DIM initializes all elements with 0, that’s intended.
The idea is, that you don’t spell a variable name badly without noticing.
nathanielbabiak 2022-03-26 00:00
I'm out of tokens on a project. The line X=X+1 within a loop saves one or two tokens depending on the control structure. I'll limit the code to intended behavior only.
(FYI on the topic of DIM, that's shown in the manual explicitly.)
was8bit 2022-03-26 09:07
"The idea is, that you don’t spell a variable name badly without noticing."
Yes, I am VERY grateful for this check!!! In original LowRes it was TERRIBLE as I would often mistype variable names, and if the code was big and I edited a lot of code before testing it, it would take me a TON of effort trying to find out why my code was acting weird...
It had gotten to the point that i got into the habit of test running whenever I added every small bit of code as i made it, that way I would know that it was my last line of code that was the issue ...
The "variable not initialized" check is a WONDERFUL help :D