Variables

All variables in GPC are 16 bit signed integers. An integer (from the Latin 'integer' which means 'whole') is a number which can be written without a fractional component. For example, 0, 20, 128 and -1000 are all integers while 4.2, 5.6 or -110.9 are not. Therefore, GPC does not support fractions and will round down any decimal to a zero. Meaning 3.4 would become 3.

16 bit signed means the variables can store an integer ranging from -32768 to +32767

The following sections on variables can be found within this page;

Declaring Variables

A variable is a place where data can be stored in the Virtual Machines memory. A variables name can start with either an underscore ( _ ) or a letter and can be followed by any combination of letters, digits or underscores. They are however case sensitive, so cronuszen, CronusZen and CRONUSZEN would specify three different variables.

Variables defined this way in GPC are global, this means they can accessed and modified within the init or main sections as well as a combo or function. Only variables assigned to user created functions are local. Details of how variables operate within user functions can be found here.

Global variables must be declared before the main or init sections and therefore cannot be declared after or in either of those sections. As shown below;

int myVar = 100, MYVar;
int MYVAR = -40;
 
init {
    int incorrect; //This will cause an error
}
 
int Incorrect; //This will also cause an error
 
main {
 
    int INCORRECT; //This will again cause an error
 
}

Variables are always assigned a value. If no value is assigned when they are declared, then they are initialized with a value of 0 (zero). The value assigned to a variable can be altered during runtime, as shown below;

int myVar = 100, MYVar; // myVar initial value is 100, MYVar initial value is 0
int MYVAR = -40;        // MYVAR initial value is -40
 
main {
 
    MYVar = myVAR - MYVAR;  // MYVar value is now 60
 
}

Last updated