Dave wrote:I think there's an ambiguity in the question.
You might want to check if a variable name is set (though, is there a use case for this?)
Of course! E.g. in command files (without line numbers) where you want to pass parameters:
Code: Select all
IF BASIC_INDEX%("x_%")<0:PRINT#0,"x_% (or y_%) not set! Aborting":END_CMD
IF BASIC_INDEX%("y_%")<0:PRINT#0,"y_% (or x_%) not set! Aborting":END_CMD
IF x_%<0 OR x_%>512:PRINT#0,"x_% must be in range 0..512!":END_CMD
IF y_%<0 OR y_%>510:Print#0,"y_% must be in range 0..510!":END_CMD
PRINT#0,"Reset SuperBASIC origin to "&x_%&", "&y_%&"?";
CURSEN#0:a_$=INKEY$(#0,-1):CURDIS#0
IF a_$<>'y'AND a_$<>'Y':PRINT#0,"User abort":END_CMD
BORDER#0,2:BORDER#1,0:BORDER#0,0
PAPER#2,0,2:PAPER#1,0:PAPER#0,0:CLS#2:CLS#1:CLS#1
REMark x%=0:y%=0
BORDER#2,0:BORDER#1,0:BORDER#0,0:CLS#2:CLS#1:CLS#0
WINDOW#2,256,202,x_%,y_%:WINDOW#1,256,202,x_%+256,y_%:WINDOW#0,512,54,x_%,y_%+202
CLS#0:WINDOW#0,512,54,x_%,y_%+204
BORDER#2,1,255:BORDER#1,1,255:BORDER#0,1,255
PAPER#2,7:PAPER#1,2:PAPER#0,0:CLS#2:CLS#1:CLS#0
END_CMD
If you use this with the following hotkey:
Code: Select all
ERT HOT_KEY("r","x_%=:y_%=:DO'resetSB_bat'"&FILL$(CHR$(192),21))
Gives:
Code: Select all
x_%=<Cursor is here>:y_%=:DO'resetSB_bat'
You can easily move SuperBASIC around by setting values to x_% and y_%, without loosing the currently loaded program, variables, ...
If there are commands (I don't know any), which could read the current PAPER, INK, STRIP, SIZE, BORDER of a window, it would even be possible to move the whole SuperBASIC windows #0 to #2 without resetting them to the default.
Without checking that x_% and y_% are set, this command file will have strange effects (if x_% or y_% doesn't exist) and leaves the command file open, because END_CMD will never be called (well known bug, which is even present in Minerva).
Dave wrote:You might want to check if a variable has had a value set. Is it a value or null (aka "*")?
Yes, I must be able to detect if a variable exists and in case of an integer variable it always has a value, it cannot be "nothing" (empty) like a string variable.
Dave wrote:If a variable has ever had a value set, is there ever a way to reset it to no value set? Is there even a use case for this?
I don't think this is possible.