| All variables are created with the keyword "var." |
var v1 = "one";
var v2 = 2;
var v3 = GetWindowHandle ( "World of Warcraft" );
|
| Variables do not have types, but their values do. The first value above is a string; the second is an integer; the third is a window handle. |
| Since variables don't have types, after a variable is created any value can be assigned to it. In the following example, an integer is assigned to v1 even though v1 was initialized with a string. |
| The program converts types automatically so you don't have to think about them. For example: |
var v1 = "one";
print ( v1 + 7 ); // prints 8
|
| You also have the option of converting types manually with casts. |
v1 = int ( "999" );
print ( v1 ); // prints 999 instead of "999"
v2 = hwnd ( "World of Warcraft" );
print ( v2 ); // prints 0xA93C0
v1 = bool ( v1 );
print ( v1 ); // prints true
|
| The last cast above illustrates the meaning of "variables do not have types but their values do." Such a cast is impossible in languages whose variables have types. |
| You can overload functions by parameter type and restrict the types of arguments by which they can be called. For more information see Function Syntax. |
| The program includes the following types: |
bool
float // double precision
hwnd // window handle
int
key
keylist
label
string
wname // window name
|
Unitialized variables have values with type null.
Functions without explicit return values also have type null. |
This page was last revised on June 14, 2009 |
|
|