15 posts
Posted 22 May 2012 - 08:17 PM
How would I code that a startup program asks which option you want, then opens that program( i know this bit) but after that how would I return to the startup where I had left it?
474 posts
Posted 22 May 2012 - 08:24 PM
It automatically returns where it was.
1604 posts
Posted 22 May 2012 - 08:25 PM
When the program you run with shell.run() exits, your program continues where it was. So if you have these two programs:
Program hello:
print("Hello World!")
Your program:
print("Program starting...")
shell.run("hello")
print("Hello to you")
It would do the first print, then run the hello program that prints "Hello World!", and then it would do the last print("Hello to you").
Also, shell.run returns a boolean that indicates if the program ended correctly and any values returned by the program.
15 posts
Posted 22 May 2012 - 09:29 PM
Sorry, I forgot that both of the things I wanted were separate programs, sorry
But how would I repeat a script?
1604 posts
Posted 22 May 2012 - 11:18 PM
If you want to make a program repeat some part of the code (even the whole program), you can use a loop. There's diferent types of loops depending on how much times you need to do it. The most common is:
while true do
-- your code
end
That makes an infinite loop, so if you put your program's code inside it will run forever (until the computer shuts down or the program is terminated).
15 posts
Posted 22 May 2012 - 11:43 PM
cool thanks:)