Home > cat > vardecl 
 fr de es it nl pl pt pt_BR mk sq ca ar fa vi ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Refresh  Search  Administration  
Documentation
History
 
Variable Declaration
Syntax
[ STATIC ] { PUBLIC | PRIVATE } Identifier [ Static array declaration ] AS Datatype [ = Expression ]

This declares a class global variable.

Access

This variable is accessible everywhere in the class it is declared.

Examples

STATIC PUBLIC GridX AS Integer
STATIC PRIVATE bGrid AS Boolean
PUBLIC Name AS String
PRIVATE Control AS Object

Initialization

The variable can be initialized with any Expression.

PRIVATE Languages AS String[] = [ "fr", "it", "es", "de", "ja" ]
PRIVATE DefaultLanguage AS String = Languages[1]

Alternatively, you can initialize the variable with a newly instanciated object.

Syntax
[ STATIC ] { PUBLIC | PRIVATE } Identifier AS NEW Class ( Arguments ... )

STATIC PRIVATE Tasks AS NEW List
PRIVATE MyCollection AS NEW Collection(gb.Text)

Or you can initialize the variable with a native dynamic array.

Syntax
[ STATIC ] { PUBLIC | PRIVATE } Identifier AS NEW Native Datatype [ Array dimensions ... ]

Note that you can use any expression for specifying array dimensions.

PUBLIC CONST WORD_MAX AS Integer = 12
PRIVATE Words AS NEW String[WORD_MAX * 2]
PUBLIC Matrix AS NEW Float[3, 3]

See also

Local Variable Declaration  Method Declaration  Array Declaration  Datatypes