Menu

Basic Syntax


  1. 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 need to  terminating the last line of a GPC block.
 
main
{
    set_val(XB1_A, 75);
    x = y * ( z + 1 )
}
 

  2. Block Statement

      A group of statements which are bonded together to form a logic are called block statements. Block statement begins with a { and ends with a }.
 
main {
    if( a <= 120 ) {
        z = a + 10;
        {
            b = a + 20;
            c = b / z;
        }
    }
}
 

  3. Defines

      Defines a named constant at compile time. Defines MUST be defined before the main procedure.
 
define <name> = <value>;
- <name>:  The name of the constant.
- <value>: The value of the constant; only scalar values are allowed.
 
define MODE_OFF = 0;
define MODE_A = 1, RFA_TIME = 20;
 
int mode = MODE_OFF;
 
main {
    if(mode == MODE_A) mode = MODE_OFF;
}
 

  4. Comments

      GPC supports C style comments. For example:
 
main
{
    block(PS4_START, 200); // This is a one-line C style comment
    /* This is a multi-line comment
      yet another line of comment */
    set_val(PS4_GYROY, 45);
}
 
      The "one-line" comment style only comment to the end of the line. Multi-line style comments end at the first */ encountered. Make sure you don't nest C style comments. It is easy to make this mistake if you are trying to comment out a large block of code.
 
main
{
/*
    set_val(XB1_RT, 45); /* This comment will cause a problem */
*/
}