GPC variables and arrays
Understand signed 16-bit runtime values, global storage, local scope, initialization, and safe array indexing.
Overview
Standard GPC variables are signed 16-bit integers. That range affects arithmetic, counters, controller values, and intermediate results.
Arrays group indexed values. Keep indexes within declared bounds and be deliberate about global versus function-local lifetime.
Key facts
- GPC variables are signed 16-bit integers.
- Global declarations appear before runtime blocks.
- An array index must remain within the declared element range.
- Overflow-sensitive arithmetic should be redesigned or checked against current compiler behavior.
GPC syntax examples
Examples are intentionally small. Replace identifiers only with values documented for your target.
int enabled = FALSE;
int levels[3] = { 25, 50, 75 };
main {
if (enabled) {
set_val(XB1_A, levels[1]);
}
}Functions, commands, and terms
Names below are catalog entries, not guessed signatures. Open the official sources for current parameter and return-value details.
intdeclarationDeclares signed 16-bit runtime variable storage.
int[]declarationDeclares indexed signed-integer storage.
Common mistakes
Assuming standard variables are 32-bit.
Using a negative or out-of-range array index.
Relying on an uninitialized value instead of assigning intentionally.
Official GPC sources
Use these first-party references to confirm exact syntax and runtime behavior for your installed firmware and Studio version.
Related GPC references
Build conditions and loops with comparison, logical, arithmetic, assignment, if, else, while, for, break, and continue.
StatePersistent variables: PVAR and SPVARStore bounded settings in Zen global or slot-private persistent memory and load safe defaults.
LanguageDefinitions and constants in GPCUse define declarations and built-in identifier constants without confusing textual names with runtime variables.