Decide how long data should live
THE BASIC LANGUAGE
A counter used during one calculation, a counter private to a record, and a flag saved with the game each need a different home.
DIM visits AS Integer = 0FUNCTION Run()
visits += 1
RETURN visits
END FUNCTIONWhat you should see Two calls to the same unchanged record returned 1 and 2. The DIM sits above FUNCTION, so both calls see the same private counter.
GLOBAL signal_seen AS Boolean = FALSEFUNCTION Run()
signal_seen = TRUE
RETURN signal_seen
END FUNCTIONGLOBAL uses the game’s shared, saveable variables. In the editor runtime, saving with signal_seen true, clearing it, and loading the slot restored true. Use a distinct name for every flag that means something different.
| Inside a function | DIM belongs to that call. It starts again next time. |
|---|---|
| At the top of the record | DIM or top-level STATIC retains private state until the module/cache is reset. Editing or reloading can reset it. |
| Across records and saves | GLOBAL or SHARED gives other records and the save system access. Local STATIC inside a function is unsupported. |
