function main()
local l_option = io.stdin:read'*l'
print("l_option: \'" .. l_option .. "\'")
end
startMacro(main)
Displays:
Any ideas how I can remove the script name from the buffer before I start asking for input? It is not a big deal for me since my scripts get called by batch files so nothing is in the buffer then, but just thought it's worth mentioning.
Indeed. This can be confusing for people who are not familiar with working with console input. Generally, it's good practice to clear both the standard IO buffer and keyboard buffer directly before trying to read any information. In your example, you could get away with just clearing the keyboard buffer, since that information has already been popped from the IO buffer.