INSTANCE statement

Purpose | Declare INSTANCE variables which are unique to each object.
Syntax | INSTANCE variable[()] [AS type] [, variable[()]] INSTANCE variable[()] [, variable[()]] [, ...] AS type

Remarks

INSTANCE statements are used to declare instance variables for an object. A unique set of instance variables is created for every new object, which may only be referenced from within that object. INSTANCE statements may only be placed at the beginning of a CLASS/END CLASS block, preceding all INTERFACE blocks.

INSTANCE will optionally accept a list of variables, each of which are defined by the descriptor which follows it:

INSTANCE x as integer, y as long

INSTANCE will also accept a list of variables, all of which are defined by the single descriptor at the end of the list;

INSTANCE aaa, bbb, ccc AS INTEGER

INSTANCE vptr, aptr() AS LONG PTR

To declare an array as an instance variable, use an empty set of parentheses in the variable list: You can then use the DIM statement to dimension the array.

See also | GLOBAL, INTERFACE (Direct), LOCAL, STATIC, THREADED, What is an object, anyway?