×
Menu

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 CronusMAX PLUS.  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.  Note only Integer values can be used.
 
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);  //Set RT / R2 to 50
 
    myvar = my_value;           //myvar equals 50
 
    if(myvar >= my_value) {     //If myvar is greater than or equal to 50
        //Do Something
    }
 
    if(get_val(XB1_LT) > my_value) {  //If LT / L2 is greater than 50
        //Do Something
    }
 
}
 
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//This will produce a compiler error
 
}
 
If you wished to assign a value to a word and change its value during runtime, you would use a variable instead of a define.