gforth : how to check a variable is set
I currently set a variable from command line like :
: functionname
variable !
;
so it gets its value from
gforth -e"5" myfile.fs
but then I would ensure the variable is set by a default value even if user runs
gforth myfile.fs
how can I check variable is set ? (then I can give it a default value in a if statement)
finally I changed method for reading the parameter :
first the function is now like :
: valorise_hauteur
argc @ 2 < if
cr
." no argument using default 5 value"
5 hauteur !
cr
else
1 arg s>number drop hauteur !
endif
;
and I can call the full script :
gforth myscript.fs 10
where 10 is my arg number 1 this method is more command line way to do that & permit to use a default value.