Please enable JavaScript to view this site.

Variables used in a X/script source are declared by specifying the type first and then the name.

Declarations must be at the beginning of the line and their scope starts from the declaration point: if a variable is declared inside a function body, its scope will end as the function body ends, otherwise the scope will end with the end of the source.

After the variable name, an initialization value can be specified; more variables of the same type can be declared on a single line.

<type> <variable> [, < variable> ...]

where <type> is the data type, and <variable> is:

<variable> => <name> [= <initializer>]

A special declaration is needed for string with declared maximum size:

<variable> => <name> (<size>) [= <initializer>]

If you are declaring an array of variables, you cannot use the initializer, so the full declaration is:

<variable> => <name> <array>

where <array> is a unsigned integer value between symbols [ and ]. You cannot define an array with more than one index, like matrices or other similar.

Notes:

the X/script compiler implementation will fix a default size for variables (usually 128 characters), so any string variable cleared without the <size> specification will assume the compiler default size;

all uninitialized variables are automatically initialized with zero values from the compiler;

<type> can be a predefined or user defined (object) data type.

Examples:

; Multiple int variables

int var1, var2;

 

; Array of floating variables

float var3 [10]

 

; Initialized real variable

real quote = 10.0;

 

; Initialized standard string

string text = "A text variable..."

 

; Empty string variable with custom maximum size of 256

string text2(256) 

 

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Contents: ALT+c
Search: ALT+s
Exit Menu/Up: ESC