SP4CEBAR 2024-11-29 21:50 (Edited)
I just realized I don't need to initialize a global variable, the following code is valid:
GLOBAL TEST
PRINT TEST
Now I can write this:
GLOBAL COMPLEX_T, RE, IM
CALL STRUCT_2( COMPLEX_T, RE, IM )
Timo 2024-11-29 22:10
The important thing is, that the variable is somehow defined before it‘s read.
GLOBAL is just another way to define a variable.
nathanielbabiak 2024-11-30 00:46
been using this for years, didn't realize it's not explicit in the manual. I'll add it to my clarifications post when I'm back from Thanksgiving travels, if it's not in the manual already...
nathanielbabiak 2024-11-30 01:12
Confirmed - this is not in the manual. Good idea pointing it out, and making it explicit Sp4cebar!
was8bit 2024-11-30 16:03 (Edited)
The idea for flagging a variable that is not "defined" is to eliminate the issues of errors caused by the programmer mistyping their variables...
So, originally, if you have a variable Myvariable, and you had a line...
NextX=32+Myvsriable
Your game would behave irrationally, and at quick glance if you never realized the miss spelled variable, you could not fix this... i often spend HOURS reading each and every word typed in my code, just to find a misspelled variable deep in the code... as an immediate fix, i had to resort to entering in only one line of code... run it immediately to flush out any misspellings, then repeat...
So, if you use GLOBAL Myvariable, it is assumed you spelled it right, and if wrong you should quickly see it and fix it...
Same thing happens with Arrays... defining an array automatically lets you use them, you are not required to first add a value to an array before you can use it...
Using a variable that has not...
1) been assigned a value
2) been initially defined as an array
3) been initially defined as GLOBAL
will incure an ERROR, as there is a chance it might be a typo...
As i have very mild dyslexia and if i get stressed (as in my code is behaving irradically) i can sometimes type DOPRITN and actually see DOPRINT ... so having a mispelled check is wonderful :)
nathanielbabiak 2024-12-04 04:29 (Edited)
Done. Updated (and finally proof-read-and-edited!) my sticky post on Detailed Nuances of LowRes NX.