5 posts
Posted 01 July 2013 - 02:07 PM
title: user input to run a program
i want a program to be able to detect user input then use a if then statement to run a specific program or depending on what they input i want a specific program to run and i cant figure out how to do it with the 20 hours of research ive done
3790 posts
Location
Lincoln, Nebraska
Posted 02 July 2013 - 04:29 PM
You're looking for arguments. To do this, you want to use a table like so:
local tArgs = {...}
if tArgs[1] == "stuff" then
--do stuff
end
The {…} puts anything input after the program name into a table separated with spaces. So if I run "programName stuff", it will run with the argument "stuff".
Keep in mind anything returned from the arguments table is a string, so if you want numbers, you need to use tonumber().
159 posts
Location
A Chair
Posted 02 July 2013 - 05:32 PM
to run another script…
shell.run("") – inside the quote marks place the name of your program and all variables.
this calls the second program from inside the first. (I use this to run programs on monitors eg. have a file named startup with the following line of code :-
shell.run("monitor top server01")
This starts the computer with the monitor as the output and runs the servers output to the screen. But i called it from startup - even though my server file is called server01…