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.

Examples
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

As of FB 7.0.16, 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