- This wiki is out of date, use the continuation of this wiki instead
OnExit
From FenixWiki
Definition
Begin
<main code>
[OnExit
<exit code>]
End
The OnExit statement can be used between the Begin and End statements in the Program, Process or Function. When the Program, Process or Function is killed, the exit code starts.
This can be easily used to free any memory used by the exiting process.
Notes
Be advised, Frame statements are interpreted as Frame(0) statements, so the instance will be killed eventually. Code like
Loop frame; End
will cause Fenix to freeze, as frame(0); doesn't allow the program to continue.
Example
Program example; Begin // Start the main code part of the main process proc1(); // create new instance of proc1 Loop frame; End OnExit // Start the exit code of the main process End Process proc1() Begin // Start the main code part of the process Loop frame; End OnExit // Start the exit code of the process End Function int func1() Begin // Start the main code part of the function return 0; OnExit // Start the exit code of the function End
Used in example: loop, end, program, process, function
A good use for this is the following:
Process ship() Begin graph = new_map(20,20,8); Loop frame; End OnExit unload_map(0,graph); End
Used in example: new_map(), unload_map(), graph, loop, frame, end