This wiki is out of date, use the continuation of this wiki instead

OnExit

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 13:41, 24 July 2007 (edit)
Sandman (Talk | contribs)
(New page: category:reserved category:language category:basic statement '''Up to Basic Statements''' ---- == Definition == '''Begin'''<br> <main code><br> ['''OnEx...)
← Previous diff
Revision as of 13:42, 24 July 2007 (edit) (undo)
Sandman (Talk | contribs)
m (Onexit moved to OnExit: zomg)
Next diff →

Revision as of 13:42, 24 July 2007

Up to Basic Statements



Definition

Begin
<main code>
[OnExit
<exit code>]
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

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

Personal tools