Force termination

I have an instance where I want to force the program (a game) to terminate and cannot find a routine which will do this. I have tried assert() and error() and neither terminates the application.

Rational: typically this would be a strange request but I am using it as a fail-safe. When my program ends I save the state in a file, which is a complicated data structure. On restart I restore it, using pcall(…) as protection. In the off chance it fails, I delete the saved state file and terminate. Thus when it restarts next time it will return to a clean initial state.

Without such protection I worry about the user never being able to run the program again without strange behavior. [import]uid: 1813 topic_id: 627 reply_id: 300627[/import]

have you tried

os.exit ([code])
Calls the C function exit, with an optional code, to terminate the host program. The default value for code is the success code.

carlos

ps: i have not tried it. [import]uid: 24 topic_id: 627 reply_id: 1238[/import]

Works like a charm (at least in the simulator). Did not even think to look in the “os” routines.

Thanks for the prompt reply.

Kent [import]uid: 1813 topic_id: 627 reply_id: 1239[/import]

Oh small thing, it also seems to terminate the simulator… [import]uid: 1813 topic_id: 627 reply_id: 1240[/import]

nice… it works as designed… (OOOPS!)

c [import]uid: 24 topic_id: 627 reply_id: 1241[/import]