GPC Developer Guides
Main Section
the main section is the heart and soul of any gpc script it is run in a constant loop from the top down and any code executed during run time can be traced back to it therefore, the main section is mandatory and a gpc script is not valid without one just as with any nested code, the main section start and finish points are denoted with a { or } respectively, like so; gpc main { // main start } // main end when the main section reaches the endpoint, the output report to the console is created, any remaps are evaluated and the report is sent to the console the main section is then restarted from the beginning the code within the main section is executed in the order it is written it is important to remember this when building your own gpc scripts as the output report to the console is created at the end of the main section, so it is possible to create code that would cancel each other out and result in a different output to the console than you expected for example; gpc int hold lt; main { if(get val(xb1 rt)) { hold lt = true; } hold lt = false; if(hold lt) { set val(xb1 lt, 100); } } as you can see above, the variable 'hold lt' is set to true when the rt/r2 button is pressed but is immediately set to false in the next line of code therefore the if(hold lt) statement will always be false and the code nested within the if statement will never be executed however, if we were to move the code around, then we would get the expected output gpc int hold lt; main { hold lt = false; if(get val(xb1 rt)) { hold lt = true; } if(hold lt) { set val(xb1 lt, 100); } } if rt/r2 is pressed then hold lt is set to true after it has been set to false , the if(hold lt) statement will see that it is true and the nested code will be run if rt/r2 isn't being pressed then 'hold lt' is not set to true after it has been set to false and the nested code is not run so, as you can see in the above examples, it is important to remember that code is executed in the order it is written and simply moving the placement of a line can have a significant effect on the output to the console