FutureBasic Logo

<<    Index    >> FutureBasic

static   statement



Syntax
static VarType varName

Description
Place the static keyword before a variable declaration in a function to make the variable 'global' to that function.

Normal variables are destroyed once the function has ended but static variables remain in memory for the life of the program.

Example 1

local fn DoCounter as long
static long sCounter

sCounter++
end fn = sCounter

long i
for i = 1 to 10
NSLog(@"Counter = %ld",fn DoCounter)
next

HandleEvents

Example 2

Multiple static variables can be declared on the same line.

local fn MyFunction

static long sVar1, sVar2, sVar3
// ...
end fn
See also
begin globals; dim