Revision as of 13:41, 24 July 2007 (edit) Sandman (Talk | contribs) ← Previous diff |
Current revision (13:42, 24 July 2007) (edit) (undo) Sandman (Talk | contribs) |
Line 1: |
Line 1: |
- | [[category:reserved]] | + | #REDIRECT [[OnExit]] |
- | [[category:language]] | + | |
- | [[category:basic statement]] | + | |
- | | + | |
- | [[Basic statements|'''Up to Basic Statements''']] | + | |
- | ---- | + | |
- | | + | |
- | | + | |
- | == Definition == | + | |
- | '''Begin'''<br> | + | |
- | <main code><br> | + | |
- | ['''OnExit'''<br> | + | |
- | <exit code>]<br> | + | |
- | '''End''' | + | |
- | | + | |
- | The [[OnExit]] statement can be used between [[Begin]] and [[End]]. The exit code starts at the [[OnExit]] statement, when the [[Program]], [[Process]] or [[Function]] is killed. | + | |
- | | + | |
- | == Notes == | + | |
- | Be advised, [[Frame]] statements are interpreted as [[Frame]](0) statements, so the [[instance]] will be killed eventually. Code like | + | |
- | <pre> | + | |
- | Loop frame; End | + | |
- | </pre> | + | |
- | will cause Fenix to freeze, as frame(0); doesn't allow the program to continue. | + | |
- | | + | |
- | == Example == | + | |
- | <pre> | + | |
- | 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 | + | |
- | </pre> | + | |
- | Used in example: [[loop]], [[end]], [[program]], [[process]], [[function]] | + | |
- | | + | |
- | A good use for this is the following: | + | |
- | <pre> | + | |
- | Process ship() | + | |
- | Begin | + | |
- | graph = new_map(20,20,8); | + | |
- | Loop frame; End | + | |
- | OnExit | + | |
- | unload_map(0,graph); | + | |
- | End | + | |
- | </pre> | + | |
- | Used in example: [[new_map]](), [[unload_map]](), [[graph]], [[loop]], [[frame]], [[end]] | + | |