Variables can be declared globally, with GLOBAL, or locally, with LOCAL.
Constants can be declared with CONST.
An example demonstrating Local and Global variables:
Global var1 := 57; Global var2 := 58; Const BAR := 102; function foo() begin Local i; for( i := 0; i < 10; i := i + 1 ) begin print "i=" + i; Local text := "hello world"; print(text); print(BAR + var2); end // text does not exist here end foo(); |
Variables are destroyed at the end of the block in which they are declared. In
the FOR loop above, the variable "text" is created, assigned, and destroyed on
every iteration. var1 and var2 are accessible within foo(). |
CONST values are substituted where used at compile-time.