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

Process

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 11:01, 26 March 2007 (edit)
FCR (Talk | contribs)

← Previous diff
Current revision (23:57, 8 August 2008) (edit) (undo)
Sandman (Talk | contribs)
m (Statement)
 
(12 intermediate revisions not shown.)
Line 1: Line 1:
 +[[Category:General]]
 +[[category:reserved]]
 +[[category:language]]
 +[[category:basic statement]]
 +
 +[[Basic statements|'''Up to Basic Statements''']]
 +----
 +
== Definition == == Definition ==
-A process is a [[subroutine]] to which one or more of the following apply:<br />+=== Statement ===
-*it received [[parameters]]<br />+'''Process''' <name>([<parameters>])<br>
-*it acts on the [[parameters]]<br />+['''Public'''
-*it processes [[data]] located elsewhere<br />+:<public variables>]
-*it [[returns]] a value<br />+['''Private'''
 +:<private variables>]
 +'''Begin'''
 +:<main code>
 +['''OnExit'''
 +:<OnExit code>]
 +'''End'''
-In addition to these possibilities, a process ''always'' has a [[frame]]; statement. The difference between a [[function]] and a process is a process is treated as a seperate thread. This means one can't let a process return a value, as the [[father]] process continues its code as well. When a process comes to its first frame; statement, the process 'returns' its [[ProcessID]] and continues the code (in the next frame).+Process is a reserved word used to start the code of a process. If ''name'' is ''Main'', that process will be started at the start of the program (see [[Program]]).
-In earlier [[Fenix]] versions (2005 and earlier) there is no difference in [[syntax]], however, a process is treated like a [[function]] when there is no [[frame]]; statement in the [[code]].+=== Concept ===
 +A process is a [[subroutine]] to which one or more of the following apply:
 +*it receives [[parameter]]s
 +*it acts on the [[parameter]]s
 +*it processes [[data]] located elsewhere
-When the [[frame]]; statement is reached in the code, a number of other local variables are defined or updated not only of the new process, but also of related processes. These are:+In addition to these possibilities, a process ''always'' has a [[frame]]; statement. The difference between a [[function]] and a process is a process is treated as a separate thread. This means one can't let a process return a value like a function, as the [[father]] process continues its code as well, as soon as the process hits a frame; statement or when the code is done. When that happens, the process 'returns' its [[ProcessID]] and continues the code (in the next frame).
 + 
 +In earlier [[Fenix]] versions (2005 and earlier) there is no difference in [[syntax]], however, a process is treated like a function when there is no frame; statement in the [[code]].
 + 
 +When the frame; statement is reached in the code, a number of other local variables are defined or updated not only of the new process, but also of related processes. These are:
*The [[father]] variable of the new process. *The [[father]] variable of the new process.
-*The [[son]] variable of the [[father]] process (updated).+*The [[son]] variable of the father process (updated).
*The [[bigbro]] variable of the new process. *The [[bigbro]] variable of the new process.
-*The [[smallbro]] variable of the processes called by the [[father]] immediately before the new process was called (updated).+*The [[smallbro]] variable of the processes called by the father immediately before the new process was called (updated).
-*The [[son]] and [[smallbro]] variables are also defined of the new process, but do not yet carry values.+*The [[son]] and smallbro variables are also defined of the new process, but do not yet carry values.
-== Example ==+When there are no more processes alive, the program ends.
 +== Example ==
<pre> <pre>
-Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed )+Process SpaceShip( int x, int y, int angle, int maxspeed, int maxturnspeed)
-Private+Public // Declare public variables here (Fenix 0.86 and up)
 +Private // Declare private variables here
int speed; int speed;
-Begin+Begin // Start the main processcode
 + graph = new_map(20,20,8);
 + map_clear(0,graph,rgb(0,255,255));
Loop Loop
speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed); speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed);
Line 31: Line 57:
frame; frame;
End End
-End+OnExit // Start the exit code (Fenix 0.90.2 and up)
 + unload_map(0,graph);
 +End // End the main processcode
</pre> </pre>
Now one can call this process for example by doing the following. Now one can call this process for example by doing the following.
<pre> <pre>
-Private+Process Main()
- int map;+
Begin Begin
- map = new_map(20,20,8);+ SpaceShip(100,100,0,20,5000);
- map_clear(0,map,rgb(0,255,255));+ Repeat
- SpaceShip(0,map,100,100,0,20,5000);+ frame;
 + Until(key(_ESC))
 + let_me_alone();
End End
</pre> </pre>
-This will make a SpaceShip with a cyan coloured block, able to move around the screen.+Used in example: [[new_map]](), [[map_clear]](), [[key]](), [[advance]](), [[unload_map]](), [[let_me_alone]](), [[Process]], [[Begin]], [[End]], [[Loop]], [[Repeat]], [[graph]], [[angle]]
-[[Category:General]]+And when the SpaceShip process ends - because the code of it reached the End or something sent an [[s_kill]] [[signal]] - the [[OnExit]] code starts. In this example it will unload the memory used for the created [[graphic]]. If there is no OnExit code, the process will just end.
 + 
 +This will make a SpaceShip with a cyan coloured block, able to move around the screen.

Current revision

Up to Basic Statements


Contents

[edit] Definition

[edit] Statement

Process <name>([<parameters>])
[Public

<public variables>]

[Private

<private variables>]

Begin

<main code>

[OnExit

<OnExit code>]

End

Process is a reserved word used to start the code of a process. If name is Main, that process will be started at the start of the program (see Program).

[edit] Concept

A process is a subroutine to which one or more of the following apply:

In addition to these possibilities, a process always has a frame; statement. The difference between a function and a process is a process is treated as a separate thread. This means one can't let a process return a value like a function, as the father process continues its code as well, as soon as the process hits a frame; statement or when the code is done. When that happens, the process 'returns' its ProcessID and continues the code (in the next frame).

In earlier Fenix versions (2005 and earlier) there is no difference in syntax, however, a process is treated like a function when there is no frame; statement in the code.

When the frame; statement is reached in the code, a number of other local variables are defined or updated not only of the new process, but also of related processes. These are:

  • The father variable of the new process.
  • The son variable of the father process (updated).
  • The bigbro variable of the new process.
  • The smallbro variable of the processes called by the father immediately before the new process was called (updated).
  • The son and smallbro variables are also defined of the new process, but do not yet carry values.

When there are no more processes alive, the program ends.

[edit] Example

Process SpaceShip( int x, int y, int angle, int maxspeed, int maxturnspeed)
Public // Declare public variables here (Fenix 0.86 and up)
Private // Declare private variables here
    int speed;
Begin // Start the main processcode
    graph = new_map(20,20,8);
    map_clear(0,graph,rgb(0,255,255));
    Loop
        speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed);
        angle+=(key(_left)-key(_right))*maxturnspeed;
        advance(speed);
        frame;
    End
OnExit // Start the exit code (Fenix 0.90.2 and up)
    unload_map(0,graph);
End // End the main processcode

Now one can call this process for example by doing the following.

Process Main()
Begin
    SpaceShip(100,100,0,20,5000);
    Repeat
        frame;
    Until(key(_ESC))
    let_me_alone();
End

Used in example: new_map(), map_clear(), key(), advance(), unload_map(), let_me_alone(), Process, Begin, End, Loop, Repeat, graph, angle

And when the SpaceShip process ends - because the code of it reached the End or something sent an s_kill signal - the OnExit code starts. In this example it will unload the memory used for the created graphic. If there is no OnExit code, the process will just end.

This will make a SpaceShip with a cyan coloured block, able to move around the screen.

Personal tools