- This wiki is out of date, use the continuation of this wiki instead
Type
From FenixWiki
(Difference between revisions)
Revision as of 12:51, 14 November 2007 (edit) Sandman (Talk | contribs) m ← Previous diff |
Revision as of 09:27, 1 March 2008 (edit) (undo) Sandman (Talk | contribs) (→Example) Next diff → |
||
Line 12: | Line 12: | ||
=== Example === | === Example === | ||
+ | |||
+ | A file with name and path. | ||
<pre> | <pre> | ||
- | + | Type _file | |
+ | String path; | ||
+ | String name; | ||
+ | End | ||
+ | Process Main() | ||
+ | Private | ||
+ | _file myFile; | ||
+ | Begin | ||
+ | |||
+ | myFile.path = "C:\"; | ||
+ | myFile.name = "autoexec.bat"; | ||
+ | say(myFile.path + myFile.name); | ||
+ | |||
+ | Repeat | ||
+ | frame; | ||
+ | Until(key(_ESC)) | ||
+ | |||
+ | End | ||
+ | </pre> | ||
+ | |||
+ | A point with x and y. | ||
+ | <pre> | ||
// Declare the type _point | // Declare the type _point | ||
Type _point | Type _point | ||
Line 26: | Line 49: | ||
End | End | ||
+ | Process Main() | ||
Private | Private | ||
_point p1,p2; | _point p1,p2; |
Revision as of 09:27, 1 March 2008
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
A file with name and path.
Type _file String path; String name; End Process Main() Private _file myFile; Begin myFile.path = "C:\"; myFile.name = "autoexec.bat"; say(myFile.path + myFile.name); Repeat frame; Until(key(_ESC)) End
A point with x and y.
// 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 Process Main() 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:
|