This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
os.reboot()'s profile picture

How to stop the program continuing (in code)

Started by os.reboot(), 22 July 2012 - 11:44 AM
os.reboot() #1
Posted 22 July 2012 - 01:44 PM
I'm making a command for a program ".exit" and it needs to stop the program immediately.
I don't want to hear about os.reboot() and os.shutdown().
Teraminer #2
Posted 22 July 2012 - 01:57 PM
you mean just stop or stop and wait for something?
os.reboot() #3
Posted 22 July 2012 - 02:00 PM
you mean just stop or stop and wait for something?

Like exit the program and go back to the OS's command line.
KevinW1998 #4
Posted 22 July 2012 - 02:03 PM
you need only use "return" or you can use "error()" while you are in function
os.reboot() #5
Posted 22 July 2012 - 02:37 PM
you need only use "return" or you can use "error()" while you are in function

Thank you!
Teraminer #6
Posted 23 July 2012 - 11:01 AM
No need for that just end your program.And when it ends it will automaticly "put" you in the OS command line.
kotorone1 #7
Posted 24 July 2012 - 05:10 AM
shell.programs() perhaps?
that should exit whatever you are running immediately
Noodle #8
Posted 24 July 2012 - 09:27 AM
^ Will not. It continues if you are in a loop.
Run a function that simply doesn't exist. It'll return an error :)/>/> only problem is no-clear.
If inside a loop (while true) then use break.
AlejoAy #9
Posted 21 November 2012 - 01:00 PM
i had the same problem,
you can use an if statment like so

while true do

if input == x then

elseif input == "2" then

elseif input == "3" then

elseif input == "4" then
break
else

end
end


yo can break the loop when you want, just by adding "break", you can also as i did use multiple elseif statments and place the brake where you need it.
I hope this help you
Edited on 21 November 2012 - 12:01 PM
cmurtheepic #10
Posted 21 November 2012 - 01:22 PM
you could use.

term.clear()
end
at the end of your program.