5 posts
Posted 13 August 2013 - 11:26 AM
I'm probably going to sound like a noob here, but is there any way to forcibly terminate a program from INSIDE said program without being anywhere near the computer, and without turning the computer off, I've looked around the web for a good few hours and can't seem to find it, as I said, sorry if I sound a bit of a noob…
3790 posts
Location
Lincoln, Nebraska
Posted 13 August 2013 - 11:57 AM
Split to new topic.
You can use shell.exit() to terminate the currently running program, or you can queue the "terminate" event. Depending on your ultimate goal, there are several other ways to terminate a program internally. Post your program, and a description of what you want to do, and we can try helping you find the best way for you.
5 posts
Posted 13 August 2013 - 12:19 PM
its actually needed for a few programs, but in essence they are all
if working value is entered then
do.stuff()
else print("please input normal value")
terminate program
end
unless there is a better way of re-entering values that i could use (although one reads from a file) ill use that shell.exit() thing, seems it helps to know that the shell is the program…
8543 posts
Posted 13 August 2013 - 01:08 PM
You can simply call error(), or if it is in the main body of your program (not within a function inside your program), you can use the return keyword.
The other thing you could do is ask the user for a better value with read(), or use a sane default value and print a warning for the user.
5 posts
Posted 13 August 2013 - 02:40 PM
Thanks, not quite finished putting it through its paces, but it seems to work now, thanks for the help