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
Revision as of 14:16, 29 April 2007 (edit) (undo)
Sandman (Talk | contribs)
m
Next diff →
Line 1: Line 1:
== Definition == == Definition ==
 +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
-A process is a [[subroutine]] to which one or more of the following apply:<br />+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).
-*it received [[parameters]]<br />+
-*it acts on the [[parameters]]<br />+
-*it processes [[data]] located elsewhere<br />+
-*it [[returns]] a value<br />+
-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).+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]].
-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:
- +
-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 == == Example ==
- 
<pre> <pre>
Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed ) Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed )
Line 43: Line 40:
End End
</pre> </pre>
 +Used in example: [[key]](), [[advance]](), [[new_map]](), [[map_clear]](), [[angle]]
 +
This will make a SpaceShip with a cyan coloured block, able to move around the screen. This will make a SpaceShip with a cyan coloured block, able to move around the screen.
[[Category:General]] [[Category:General]]

Revision as of 14:16, 29 April 2007

Definition

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.

Example

Process SpaceShip( int file , int graph , int x , int y , int angle , int maxspeed , int maxturnspeed )
Private
    int speed;
Begin
    Loop
        speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed);
        angle+=(key(_left)-key(_right))*maxturnspeed;
        advance(speed);
        frame;
    End
End

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

Private
    int map;
Begin
    map = new_map(20,20,8);
    map_clear(0,map,rgb(0,255,255));
    SpaceShip(0,map,100,100,0,20,5000);
End

Used in example: key(), advance(), new_map(), map_clear(), angle

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

Personal tools