lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi list!

Is there a simple way (stock Lua 5.1.4) to make a Lua script behave differently depending on whether it is executed in a MSWindows shell or not?

My problem is that I usually use simple scripts that need to be executed by double-clicking on them in MSW GUI, and to avoid the "dreaded black box" from disappearing I put:
io.read'*l'
at the end of the script to pause it until a return is pressed.

This works ok, but it gets in the way when I execute the same script inside an editor (SciTE), because it forces me to press return in the output pane every time the script is executed.

I wouldn't mind if it were only for debugging sessions (I would simply comment out the io.read line), but often I need to run the script in SciTE only to capture its output (for example, it's not the only use case), maybe multiple times at different times. So this commenting in/out sometimes is very annoying.

Please bear in mind that I'm looking for something very simple (I hope that a pure Lua solution exists), otherwise I could simply write a .cmd file to call the script and add a pause at the end, but I would really want to avoid that hassle, if possible.

I hope someone has found a clever trick that can solve my problem. :-)

Thanks in advance.

-- Lorenzo