A Simple Tutorial

      In this section we would like to show the very basics of GPC in a short. First, on Gtuner, create a new empty file (menu File -> New -> Empty File) and type (or copy-and-paste) the following code:
main {
    set_val(PS4_CROSS, 100);
To compile press F7 or select Compile from the Compiler menu or click on Compile icon in the toolbar.
      This script is extremely simple, all it does is "press and hold" the button CROSS. If you have the Titan One device connected to your computer you can see this script in action using the command 'Build and Run' and opening the Device Monitor to check the state of CROSS button. The Compiler Output Panel shows the result of compilation process: warning and error messages, the size of bytecode and the amount of stack memory used by static variables and combos. Inside of parentheses you can find the percentage used of the maximum allowed.
  ------ GPC: Build started ------
  > 1: New* :
  > Bytecode size: 9 bytes (0.2%)
  > Stack memory: 0 words (0.0%)
  Build succeeded with 0 warnings...
      Keep in mind that warning messages are also a kind of error. For example write a value out of range into a variable may cause unexpected behaviors and be very hard to debug. It is highly advisable find and fix all warning problems.
      The main procedure is mandatory and every GPC script must have one. This procedure is called by VM before every report be sent to console, you can think in this procedure as a loop which only ends when the script is unloaded. The command set_val writes the value 100 into PS4_CROSS, which means press this button hard (100%). As the PS4_CROSS is not a variable, but a reference to a data structure, you can NOT make direct assignments like PS4_CROSS = 100;
Calling of main procedure
Now we're going to extend the program. Edit your script according the code below and compile it to check for errors.
    if ( get_val(PS3_CROSS) && get_ptime(PS3_CROSS) > 2000 )
        set_val(PS3_CROSS, 0);
      Here we introduced two more GPC's exclusive functions, but first let's look on if statement. If you are familiar with the basic syntax used on C language this should be easy for you. The if expression is evaluated by its boolean value; if the expression evaluates to TRUE the code inside the brackets is executed; if it evaluates to FALSE the code inside the brackets will be ignored. The get_val function returns the current value of a controller entry, in this example is the value of CROSS button. The get_ptime function returns the elapsed time of activation, in our example means how long the CROSS button is being pressed.
      All right, but what this script do? This script checks if the user is pressing the button CROSS for more than 2000 milliseconds (2 seconds), if so then it forces the release of that button (CROSS) by overwriting its value with 0. And again, you can see the script in action using the command 'Build and Run' and the Device Monitor.