I have been attempting to troubleshoot how to launch a program I write in Lua, and it seems to me that I should be launching the program from the Lua Interpreter. The First Edition of Programming in Lua tells me I should use the command prompt> lua hello.lua
. The name of my program is "hello.lua" and it is in the same folder as the Interpreter but I get the error message '=' expected near '>'. What command should I be using? Or am i doing something wrong?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Under Windows (administrator console):
ftype Lua.File=C:\utils\lua.exe "%1" %*
(where c:\utils\lua.exe is the actual path of your Lua interpreter)
assoc .lua=Lua.File
Now, you can type: hello.lua directly at the command prompt
And, if in "Computer/Properties/Advanced/Environment Variables" (Win7 example) you add .LUA to the PATHEXT variable, you can simply type: hello at the command prompt, without the extension.
回答2:
(I guess you are on some Unix or POSIX system)
Just type lua hello.lua
; the prompt>
string is given by your shell (and the prompt is generally something different and configurable).
By typing literally prompt>
you are asking your shell to run a program -or a command- named prompt
and to redirect its stdout (to what follows the >
)