StateUpdated 2026-07-24

Persistent variables: PVAR and SPVAR

Store bounded settings in Zen global or slot-private persistent memory and load safe defaults.

Overview

Persistent variables preserve small settings beyond ordinary runtime state. PVAR positions are global; SPVAR positions are private to an individual slot.

Read with explicit bounds and a default so an absent or invalid stored value resolves safely. Avoid frequent writes when a setting has not changed.

Key facts

  • Zen provides 16 global PVARs.
  • Each slot provides 64 SPVARs.
  • Across eight slots, Zen provides 512 private SPVAR positions.
  • get_pvar requires a constant identifier plus minimum, maximum, and default values.

GPC syntax examples

Examples are intentionally small. Replace identifiers only with values documented for your target.

Load a bounded settingexample.gpc
int sensitivity;

init {
    sensitivity = get_pvar(SPVAR_1, 1, 100, 50);
}

Functions, commands, and terms

Names below are catalog entries, not guessed signatures. Open the official sources for current parameter and return-value details.

NameKindPurpose
get_pvarfunction

Loads a bounded persistent value using identifier, minimum, maximum, and default.

set_pvarfunction

Stores a value in a persistent-variable position.

PVAR_*constant family

Selects one of 16 global persistent positions.

SPVAR_*constant family

Selects one of 64 private positions for the active slot.

Common mistakes

Calling get_pvar without min, max, and default.

Confusing a global PVAR with a slot-private SPVAR.

Writing on every main cycle when the value has not changed.

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