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

Write var

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 22:21, 24 July 2007 (edit)
Rincewind (Talk | contribs)
(not-pointer info moved to notes)
← Previous diff
Current revision (00:18, 15 November 2007) (edit) (undo)
Sandman (Talk | contribs)
m (Errors)
 
(One intermediate revision not shown.)
Line 23: Line 23:
'''INT''' : [[TextID]] '''INT''' : [[TextID]]
{| {|
-| 0 || - Error. The text could not be obtained or was empty.+| -1 || - Error.
|- |-
-| !0 || - The [[TextID]] of the text.+| >=0 || - The [[TextID]] of the text.
|} |}
Line 38: Line 38:
== Errors == == Errors ==
-''<If someone knows, please edit!> ''+{|
 +| Too many texts onscreen || - There are too many texts on the screen.
 +|}
== Example == == Example ==
Line 44: Line 46:
Program test; Program test;
Global Global
- My_integer=0;+ my_integer=0;
- string My_string="Fenix";+ string my_string="Fenix";
- +
Begin Begin
- Write_var(0,0,0,0,My_string); 
- Write_var(0,320/2,200/2,4,My_integer); 
- Loop+ write_var(0,0,0,0,my_string);
- My_integer=rand(1,1000);+ write_var(0,320/2,200/2,4,my_integer);
- Frame;+ 
- End+ Repeat
 + my_integer=rand(1,1000);
 + frame;
 + Until(key(_ESC))
 + 
End End
</pre> </pre>
-Used in example: [[rand]]()+Used in example: [[rand]](), [[key]]()
-This will result in something like:<br/>+This will result in something like:<br>
[[Image:Write_var.png]] [[Image:Write_var.png]]

Current revision


Contents

[edit] Definition

INT write_var ( <INT fontID> , <INT x> , <INT y> , <INT alignment> , <VARSPACE var> )

Writes a variable of any kind to the screen, which will be automatically updated when the value of the variable changes. The variable will remain on the screen until deleted with delete_text().

[edit] Parameters

INT fontID - The FontID of the font to be used for the text.
INT x - The X coordinate of the text.
INT y - The Y coordinate of the text.
INT alignment - The type of alignment.
VARSPACE var - The name of any variable.

[edit] Returns

INT : TextID

-1 - Error.
>=0 - The TextID of the text.

[edit] Notes

Please note that for the varspace var parameter no pointer should be filled out, while write_int()/write_string()/write_float() do require a pointer.

There is a limit of 511 texts to simultaneously exist on the screen. The program will crash with an error when this number is reached.

The text depth can be changed by adjusting the global variable text_z.

Instead of write_var(), write_int() could be used to write an int to the screen, write_string() for a string, write_float() for a float.

[edit] Errors

Too many texts onscreen - There are too many texts on the screen.

[edit] Example

Program test;
Global
    my_integer=0;
    string my_string="Fenix";
Begin

    write_var(0,0,0,0,my_string);
    write_var(0,320/2,200/2,4,my_integer);

    Repeat
        my_integer=rand(1,1000);
        frame;
    Until(key(_ESC))

End

Used in example: rand(), key()

This will result in something like:
Image:Write_var.png

Personal tools