- This wiki is out of date, use the continuation of this wiki instead
OnExit
From FenixWiki
(Difference between revisions)
| Revision as of 14:14, 15 December 2007 (edit) Sandman (Talk | contribs) m (→Definition) ← Previous diff |
Current revision (14:15, 15 December 2007) (edit) (undo) Sandman (Talk | contribs) m (→Definition) |
||
| Line 14: | Line 14: | ||
| '''End''' | '''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. | + | 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. |
| Available since [[Fenix]] [[0.90.2]]. | Available since [[Fenix]] [[0.90.2]]. | ||
Current revision
[edit] 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.
[edit] 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.
[edit] 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
