Purpose |
Control automatic allocation of Register variables. |
Syntax |
#REGISTER {ALL | DEFAULT | NONE} |
Remarks |
Register variables may be Extended-precision floating-point variables, or 16/32-bit integer-class variables (Word, Dword, Integer, or Long). The #REGISTER metastatement determines the method of automatic allocation of Register variables. The #REGISTER metastatement works at two levels - a "global" setting, and a "local" setting for each Sub/Function/Method/Property. To set the global default #REGISTER options, it must precede all executable code. To override the global register option for an individual routine, it must be placed between the FUNCTION/END FUNCTION, SUB/END SUB, METHOD/END METHOD, or PROPERTY/END PROPERTY pairs before any executable code. |
ALL |
#REGISTER ALL requests automatic allocations of all possible Register variables, both integer-class and Extended-precision float variables. |
DEFAULT |
#REGISTER DEFAULT (default) requests automatic allocations of integer-class variables in all cases, and Extended-precision floating-point variables located in a routine which contains no reference to another procedure. |
NONE |
#REGISTER NONE disables automatic assignment of Register variables. You can still use the REGISTER statement to explicitly define Register variables in your code on an individual basis. This provides a way to hand-optimize your code to help obtain the utmost performance. |
Restrictions |
PowerBASIC transparently prevents the automatic register conversion of the variable used in the TO clause of the DIALOG SHOW MODAL and DIALOG SHOW STATE statements. If the target variable is explicitly declared as a register variable, PowerBASIC raises a compile-time Error 491 ("Invalid register variable"). This is necessary as the result values stored in such variables may be assigned from the context of other procedures, and this may only occur with a memory variable. |
See also |
|
Example |
#REGISTER DEFAULT ' global register setting FUNCTION PBMAIN() AS LONG #REGISTER NONE ' No automatic register ' vars in this function REGISTER x& ' Explicitly declare x& … END FUNCTION |