GPC Scripting


Here you will find some code examples by actions you may want to do.

An easy way to get into GPC scripting is by starting with some basic existing code examples. Spend close attention to the keywords used and looking them up in the GPC Language Reference to get to know them.
The reference lists information of what a keyword does along with some example code and reference to other keywords doing something similar.

The GPC scripting language is very similar to C. For information about control statements like if / if else / for / while.. search the web for c programming flow control.

Like most programming languages GPC requires you to be careful to use the right syntax. Any character at a wrong place can cause errors. Especially a missing or misplaced character of , ; { } [ ] ( ) can make it hard to find the real position of the error.

Some tips

  1. Read/type each line carefully
  2. Don't change or add to much code at once
  3. Hit the compile button often to check for errors
  4. The GPC script language comes standard with many built-in functions and commands, you can not use those as names for variables or functions. GPC Language Reference

Basic GPC IDE usage

I assume you have GTuner IV installed already.

Create your script file

Start GTuner IV now and create a New Minimum GPC Script:
Top Menu: File→New→Minimum GPC Script or press Ctrl + N , name your file
Your created script file will be opened in the GPC Script IDE automatically.
I have added the init { } section to the script file.

#pragma METAINFO("Script Name", 1, 0, "Script Author")
init {
main {
  • The first line #pragma METAINFO(“Script Name”, 1, 0, “Script Author”) defines the information that will be displayed via GTuner IV when the script is installed to a slot or parsed when uploaded to the Online Resource.
  • The init {} section is run once on start of the script.
  • The main {} section is run each 1ms (and faster, so you can't rely on it that 1ms has passed since the last run).

Compile your script

Top Menu: Compiler→Compile or press F7

Check the Output Panel for Error and Warning message and more information.
Double clicking on a line will jump to the line where the Error occurred.
The real error may be in that line or a line above that one if there is a missing ; or something similar. If you can't spot the source of the problem easily check your latest modifications since your last successful compile.
If you still can't spot it you probably haven't followed the tips closely enough.

Testing your script

You can run your script from within GTuner IV directly, without needing to install it into a slot of your Titan Two by clicking the green arrow/“Run” button or press F5

Using the “Device Monitor” will allow you to see your input (left side) and the actions performed by the script (right side).

If you drag a label from the left side INPUT to one of the 4 Channels fields (where the big rotary knob Horizontal is) you will only see the input recognized by the Titan Two for that button/input. To see the output you have to drag one from the list on the right side OUTPUT.

Hit the RUN button to start/stop the writing to the graph.

Installing your script

To install your script to a slot of your Titan Two open the script in the “GPC Script IDE” and make it the active tab if you have multiple script open.

Install it via Menu: File→Install To→Memory Slot Nr - Select one available slot number. 1)

1) Slots 4-9 are only available when using a sd-card
t2/gpc_scripting.txt · Last modified: 2019/05/25 08:43 by scachi