我正在用红色语言编写一个控制台程序(目标 MSDOS),我需要让用户输入一个字符或字符串,然后按Enter.
我似乎无法找到如何去做,我已经阅读了这里的文档(http://www.red-by-example.org/index.html)但无济于事。
我试过这样的事情:
read.red
Red [
]
print "Please make your choice then press Enter"
x: input
print x
Run Code Online (Sandbox Code Playgroud)
它在“红色控制台”中工作,red read.red但是当我编译时red -r -t MSDOS read.red出现错误:
Compiling C:\apps\red-read\read.red ...
*** Compilation Error: undefined word input
*** in file: C:\apps\red-read\read.red
*** near: [
input
]
如何从 Red 控制台程序请求输入?
我正在使用红色版本:--== Red 0.6.3 ==--.
好的,我做了一些测试并让它在我的最后工作。你需要两件事。
1) 您需要最新版本,而不是 0.63。您可以从下载页面从 master 获取自动构建。
2)您需要在文件中引用才能使用控制台。这是更新后的代码,可在最新版本的 Windows 上运行。
Red [
]
#include %environment/console/CLI/input.red
print "Please make your choice then press Enter"
x: input
print x
Run Code Online (Sandbox Code Playgroud)
这些信息被隐藏在 github 上的一篇文章中。此外,您对 MSDOS 的看法是正确的。