- This wiki is out of date, use the continuation of this wiki instead
Type
From FenixWiki
(Difference between revisions)
Revision as of 12:45, 14 November 2007 (edit) Sandman (Talk | contribs) m (→Example) ← Previous diff |
Revision as of 12:51, 14 November 2007 (edit) (undo) Sandman (Talk | contribs) m Next diff → |
||
Line 55: | Line 55: | ||
</pre> | </pre> | ||
Used in example: [[write]](), [[key]](), [[draw_line]]() | Used in example: [[write]](), [[key]](), [[draw_line]]() | ||
+ | |||
+ | This will result in something like:<br> | ||
+ | {{Image | ||
+ | | image = Type.PNG | ||
+ | | caption = A line and its distance | ||
+ | }} | ||
== ProcessType == | == ProcessType == | ||
Line 96: | Line 102: | ||
</pre> | </pre> | ||
Used in example: [[write]](), [[key]]() | Used in example: [[write]](), [[key]]() | ||
+ | |||
+ | This will result in something like:<br> | ||
+ | {{Image | ||
+ | | image = Type2.PNG | ||
+ | | caption = A list of active proc's | ||
+ | }} |
Revision as of 12:51, 14 November 2007
Contents |
Datatype declaration
Definition
Type <name>
- <variables>
End
Creates a new datatype. It's handled as it it were a struct, so the declared variables are members of the struct.
Example
Program example; // Declare the type _point Type _point float x; float y; End // Declare the function distance(), because the function returns a datatype // other than int, so it needs to be declared before usage. Declare float distance(_point a,_point b) End Private _point p1,p2; Begin p1.x = 15.3; p1.y = 34.9; p2.x = 165.4; p2.y = 137.2; write(0,0,0,0,"Distance: " + distance(p1,p2)); drw_line(p1,p2); Repeat frame; Until(key(_ESC)) End Function float distance(_point a, _point b) Begin return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); End Function int drw_line(_point a, _point b) Begin return draw_line( a.x , a.y , b.x , b.y ); End
Used in example: write(), key(), draw_line()
This will result in something like:
|
ProcessType
Definition
Type <processname>
Acquires the processTypeID of a processType or function. This can be useful for example with the functions get_id() and signal().
Example
Program example; Private proc proc_id; //int could be used too Begin // Start 2 proc's proc(); proc(); proc(); // Display all alive proc's y = 0; while( (proc_id=get_id(type proc)) ) write(0,0,(y++)*10,0,"proc: " + proc_id); end // Wait for key ESC Repeat frame; Until(key(_ESC)) End Process proc() Begin Loop frame; End End
Used in example: write(), key()
This will result in something like:
|