GPC Developer Guides

Basic Syntax

This is basic syntax of a .gpc script:

GPC


Instruction Separation



As in C, GPC requires instructions to be terminated with a semicolon at the end of each statement. However, the closing tag of a block code automatically implies a semicolon, so a semicolon is not needed when terminating the last line of a GPC block.

GPC


Although the semicolon is not required in the final line of a block, it is considered good practice to use one so it is not missed should you expand on the code at a later date.

Nesting Code



Nesting code, or creating a logic block, binds code together. A Block starts with a { and end with a }. What this does is nest the code with the { and } meaning that the code is only executed when the statement before it is active.

GPC


In this example, Blocks 2 & 3 are ignored unless Block 1 is active.

So if the R2 button is not pressed, nothing happens. If R2 is pressed, then the Cronus Zen looks at Block 2. If L2 is pressed, it will run the combo RAPID_FIRE_ADS and ignore Block 3. However, if L2 is not pressed, it will ignore Block 2 and instead execute the code in Block 3 and then run combo RAPID_FIRE.

Nesting is implied if you only have one line of code after a statement. As in this example;

GPC


When compiled, the line combo_run(RAPID_FIRE); will automatically be nested within the if statement. If you wish for more than one line of code to only be executed when the statement before them is active, then you must use { and }.

Commenting Code



A comment is text which is ignored by the compiler. Comments are usually used to annotate code for future reference or to add notes for others looking at the code. However, they can also be used to make certain lines of code inactive to aid when debugging scripts. If you have programmed in C before then GPC comments will be familiar to you as it uses the same style.

There are two types of comments, the Single Line Comment and the Multi Line Comment.

Single Line Comment



The // (two slashes) characters create a single line comment and can be followed by any sequence of characters. A new line terminates this form of comment. As shown below

GPC


Multi Line Comment



The /* (slash, asterisk) characters start a multi-line comment and can also be followed by any sequence of characters. The multi-line comment terminates when the first */ (asterisk, slash) is found. As shown below:

GPC


As the comment terminates when a */ (asterisk, slash) is found, this style of commenting cannot be nested. As shown below

GPC