Definitions

The sole purpose of a definition is assign a value to a word and therefore make a script easier for a human to read. They do not use utilize any bytecode space in a script as they are not sent to the Cronus Zen. When a script is compiled the words are changed to their assigned value.

Syntax

define <name> = <value>;
<name>    : The name of the constant
<value>   : The value assigned to the constant

Only Integer values can be assigned to the value of a constant.

Once a word is defined and given a value, that word can be used anywhere in the script where a value is valid, as shown below;

define my_value = 50;

int myvar;
main {
    set_val(XB1_RT, my_value); 
    myvar = my_value;          
    if(myvar >= my_value) {    
    }
    if(get_val(XB1_LT) > my_value) { 
    }
}

A define is a static value and therefore cannot be changed during run time, as shown below;

define my_value = 50;
main {
    my_value = 70; 
}

If you wish to assign a value to a word and change its value during run-time, you would use a variable instead of a define.

Last updated