Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
gforth:如何检查变量是否设置
我目前从命令行设置了一个变量,例如:
: functionname variable ! ;
所以它的价值来自
gforth -e"5" myfile.fs
但是即使用户运行,我也会确保变量设置为默认值
gforth myfile.fs
如何检查变量是否设置? (然后我可以在 if 语句中给它一个默认值)
最后我改变了读取参数的方法:
首先功能现在是这样的:
: valorise_hauteur argc @ 2 < if cr ." no argument using default 5 value" 5 hauteur ! cr else 1 arg s>number drop hauteur ! endif ;
我可以调用完整的脚本:
gforth myscript.fs 10
其中 10 是我的参数编号 1 这种方法是更多的命令行方式来执行此操作并允许使用默认值。