- This wiki is out of date, use the continuation of this wiki instead
ProcessID
From FenixWiki
Revision as of 11:03, 18 April 2007 (edit) Sandman (Talk | contribs) m (processType) ← Previous diff |
Current revision (00:18, 19 December 2007) (edit) (undo) Sandman (Talk | contribs) m |
||
(2 intermediate revisions not shown.) | |||
Line 1: | Line 1: | ||
+ | [[category:General]] | ||
+ | |||
== Definition == | == Definition == | ||
A ProcessID is a unique identification code, for one instance of a [[processType]]. A ProcessID is always odd and larger than 65536 (2^16).<br /> | A ProcessID is a unique identification code, for one instance of a [[processType]]. A ProcessID is always odd and larger than 65536 (2^16).<br /> | ||
- | This makes it possible to use for example the [[function]] [[collision]]() in an [[if]]() statement. This is because [[collision]]() [[return|returns]] the ProcessID the [[process]] calling [[collision]]() has collided with. | + | This makes it possible to use for example the [[function]] [[collision]]() in an [[if]]() statement. This is because [[collision]]() [[return|returns]] the ProcessID the [[process]] calling [[collision]]() has collided with. Both processes and functions have processID's. |
== Usage == | == Usage == | ||
- | ProcessID is used when referring to specific [[process]] (an instance of a [[processType]]) and access/edit its [[local]] [[variables]]. The ProcessID of a | + | ProcessID is used when referring to specific [[process]] (an instance of a [[processType]]) and access/edit its [[local variables]] and/or [[public variables]]. The ProcessID of a process is found by one of the following methods: |
- | * | + | *Returned when the [[frame]]; statement is found in the process. |
- | * | + | *Returned by the [[get_id]]() function. |
- | * | + | *Returned by the [[collision]]() function. |
- | * | + | *Stored as the local variable [[id]] (holds the process' own ProcessID). |
- | * | + | *Stored as the local variable [[father]] (holds the ProcessID of the process that [[call|called the current process). |
- | * | + | *Stored as the local variable [[son]] (holds the ProcessID of the process last called from the current process). |
- | * | + | *Stored]] as the local variable [[bigbro]] (holds the ProcessID of the process called by the [[father]] immediately before the current process). |
- | * | + | *Stored as the local variable [[smallbro]] (holds the ProcessID of the process called by the [[father]] immediately after the current process). |
<br /> | <br /> | ||
- | The ProcessID can either be used as an [[argument]] for a [[ | + | The ProcessID can either be used as an [[argument]] for a [[function]] such as [[get_angle]]() or [[get_dist]]() or as a way of using the local or public variable of another process. For example, to use the [[x]] and [[y]] local variables of a [[process]]. |
== Example == | == Example == | ||
- | |||
<pre> | <pre> | ||
- | + | Program example; | |
- | int | + | |
- | + | Declare Process SpaceShip() | |
- | | + | Public |
+ | int speed = 50; | ||
+ | String name = "Galactica"; | ||
+ | End | ||
+ | End | ||
+ | |||
+ | Global | ||
+ | SpaceShip ship; | ||
Begin | Begin | ||
- | | + | |
- | | + | ship = SpaceShip(); // ship now holds the ProcessID of an instance of SpaceShip |
- | | + | // Code in SpaceShip will be executed until the first frame; is reached |
+ | |||
+ | say(ship.name + ": " + ship.speed); // We address the public variables of ship | ||
+ | |||
+ | signal(ship,S_KILL); | ||
+ | |||
+ | Repeat | ||
+ | frame; | ||
+ | Until(key(_ESC)) | ||
+ | |||
End | End | ||
- | Process | + | |
+ | Process SpaceShip() | ||
Begin | Begin | ||
+ | name = "Pegasus"; | ||
+ | speed = 60; | ||
Loop | Loop | ||
frame; | frame; | ||
Line 37: | Line 57: | ||
End | End | ||
</pre> | </pre> | ||
- | + | Used in example: [[say]](), [[signal]](), [[key]](), [[Program]], [[Declare]], [[Public]], [[Global]], [[Begin]], [[Repeat]], [[Loop]], [[frame]] | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | [[ | + |
Current revision
[edit] Definition
A ProcessID is a unique identification code, for one instance of a processType. A ProcessID is always odd and larger than 65536 (2^16).
This makes it possible to use for example the function collision() in an if() statement. This is because collision() returns the ProcessID the process calling collision() has collided with. Both processes and functions have processID's.
[edit] Usage
ProcessID is used when referring to specific process (an instance of a processType) and access/edit its local variables and/or public variables. The ProcessID of a process is found by one of the following methods:
- Returned when the frame; statement is found in the process.
- Returned by the get_id() function.
- Returned by the collision() function.
- Stored as the local variable id (holds the process' own ProcessID).
- Stored as the local variable father (holds the ProcessID of the process that [[call|called the current process).
- Stored as the local variable son (holds the ProcessID of the process last called from the current process).
- Stored]] as the local variable bigbro (holds the ProcessID of the process called by the father immediately before the current process).
- Stored as the local variable smallbro (holds the ProcessID of the process called by the father immediately after the current process).
The ProcessID can either be used as an argument for a function such as get_angle() or get_dist() or as a way of using the local or public variable of another process. For example, to use the x and y local variables of a process.
[edit] Example
Program example; Declare Process SpaceShip() Public int speed = 50; String name = "Galactica"; End End Global SpaceShip ship; Begin ship = SpaceShip(); // ship now holds the ProcessID of an instance of SpaceShip // Code in SpaceShip will be executed until the first frame; is reached say(ship.name + ": " + ship.speed); // We address the public variables of ship signal(ship,S_KILL); Repeat frame; Until(key(_ESC)) End Process SpaceShip() Begin name = "Pegasus"; speed = 60; Loop frame; End End
Used in example: say(), signal(), key(), Program, Declare, Public, Global, Begin, Repeat, Loop, frame