4 posts
Posted 24 August 2012 - 09:02 PM
What is the command I would use to do this? The first thing I tried calling ended up shutting down the OS. Since then I have tried a few other things the latest of which is shell.exit() which just seems to hang the program (not very helpful). I would like to return to a prompt without having to hold CTRL-T to stop the program.
137 posts
Location
the Netherlands
Posted 24 August 2012 - 09:25 PM
I dont fully understand the situation… with 'subroutine' you mean a program right?
In that case you can try this:
return
Sorry if it doesnt answer your question
4 posts
Posted 24 August 2012 - 09:43 PM
No I mean a local procedure… which may be called from another procedure which may be called from another procedure. For example
local function foo()
bar()
end
local function bar()
-- something happened and I need to terminate the program here... how do I do it?
end
foo()
The return statement is not going to work (only return from the top-most level will terminate the program).
137 posts
Location
the Netherlands
Posted 24 August 2012 - 11:21 PM
No I mean a local procedure… which may be called from another procedure which may be called from another procedure. For example
local function foo()
bar()
end
local function bar()
-- something happened and I need to terminate the program here... how do I do it?
end
foo()
The return statement is not going to work (only return from the top-most level will terminate the program).
Do you mean with 'something happened' that there went something wrong? Try this:
error("something went wrong")
This stops the program and shows the line-number and and the error-message in the shell
2 posts
Posted 25 August 2012 - 05:39 AM
I think what he means is this, Ill use an example of how I need it.
For example a doorlock, its set as startup so if done right the right password opens the door then reset the program so its asking for the password again, now say I throw in an "Admin/Debug" password, how would you get it to close out of the program to be at the command prompt part again?
if input == password then
print("Door Opened")
rs.setOutput(side,true)
sleep(2)
rs.setOutput(side,false)
elseif input == debug then
error("Command Prompt Accessed")
Where debug is the debugging password, because having to teminate my program to edit it is annoying, is there a way to do it like the error but without the prog name and line number?
463 posts
Location
Germany
Posted 25 August 2012 - 08:03 AM
You can use error() (yes, no params) it will terminate the program at this line and will print no line and program.
2 posts
Posted 26 August 2012 - 12:02 AM
Cool thanks.