$STATIC: Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
(Created page with "The '''$STATIC''' Metacommand allows the creation of STATIC(un-changeable) arrays. {{PageSyntax}} ::: REM '''$STATIC''' * Qbasic Metacommands require a REM or apostrophy (') before them and are normally placed at the start of the main module. * Static arrays cannot be resized. If a variable is used to size any array, it becomes $DYNAMIC. * A REDIM statement has no effect on $STATIC arrays except perhaps a duplicate definition error at...")
 
m (QBasic capitalisation)
Tag: visualeditor
Line 7: Line 7:




* Qbasic [[Metacommand]]s require a REM or apostrophy (') before them and are normally placed at the start of the main module.
* QBasic [[Metacommand]]s require a REM or apostrophy (') before them and are normally placed at the start of the main module.
* Static arrays cannot be resized. If a variable is used to size any array, it becomes [[$DYNAMIC]].
* Static arrays cannot be resized. If a variable is used to size any array, it becomes [[$DYNAMIC]].
* A [[REDIM]] statement has no effect on [[$STATIC]] arrays except perhaps a [[ERROR Codes|duplicate definition error]] at the [[REDIM]] code.
* A [[REDIM]] statement has no effect on [[$STATIC]] arrays except perhaps a [[ERROR Codes|duplicate definition error]] at the [[REDIM]] code.

Revision as of 10:02, 29 April 2022

The $STATIC Metacommand allows the creation of STATIC(un-changeable) arrays.


Syntax

REM $STATIC


  • QBasic Metacommands require a REM or apostrophy (') before them and are normally placed at the start of the main module.
  • Static arrays cannot be resized. If a variable is used to size any array, it becomes $DYNAMIC.
  • A REDIM statement has no effect on $STATIC arrays except perhaps a duplicate definition error at the REDIM code.
  • The array's type cannot be changed once DIM and a literal value sets the dimensions and element size.
  • $STATIC defined program arrays cannot be re-sized or use _PRESERVE.


Example: When a variable is used, the array can be resized despite $STATIC. The array becomes $DYNAMIC.

  
'$STATIC

INPUT "Enter array size: ", size
DIM array(size)   'using an actual number instead of the variable will create an error!

REDIM array(2 * size)

PRINT UBOUND(array)  
Note: DIM using a literal numerical size will create a Duplicate definition error.


See also:



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link