I have a LUA CLI which takes in the lua command,
Something like this
(lua)> #
Now here inorder to execute the lua file I run the command
(lua)> # dofile(“a.lua”)
I want a command which will execute the file and also pass a argument to it.
Now here I want to pass a argument to the “a.lua” file which will take this argument and call one more lua file, and this 2nd lua file is called according to the argument, So, I need to parse this argument.
Please, can somebody tell me about the parsing commands that will be used in a.lua. I mean what are the functions to be used to parse it.
Please, can somebody tell me how to pass a argument to this file “a.lua”.
This is generally not how you execute Lua files. Usually, if you have some Lua script, you execute it with this command:
lua a.lua. You don’t typeluaand then use the interface there to execute it.Using a proper command line to execute the script, you can pass string parameters to the file:
lua a.lua someParam "Param with spaces". Thea.luascript can then fetch these parameters using the standard Lua...mechanic:However, if you insist on trying to execute this using your method of invoking the interpreter (with
lua) and typing commands into it one by one, then you can do this:However, if you don’t want to do it in two steps, with the intermediate global variable, you can do it in one: