CLEAR - QB64 Wiki


From QB64 Wiki

Jump to: navigation, search

The CLEAR' statement clears all variable and array element values in a program. It does not affect constant values!

Syntax: CLEAR [, stacksize& , stackspace&]


  • Optional stacksize parameter was not required as Qbasic managed that. All parameters and commas are ignored by QB64!
  • The stackspace parameter sets the stack space to be added to the stack. Two commas kept Qbasic compatible with BASICA.
  • Normally used to clear all program variable and array values where numerical values become zero and string values become null.
  • It does not clear constant values.
  • Closes all opened files also.
  • $DYNAMIC or REDIM arrays will need to be re-dimensioned or an error will occur when referenced because it was removed.

Example: Using CLEAR to clear array elements from static arrays or arrays created using DIM.

CLS DIM array(10) 'create a $STATIC array array(5) = 23 PRINT array(5) CLEAR PRINT array(5)

Note: If you change DIM to REDIM a "Subscript out of range" error will occur because a $DYNAMIC array is removed by CLEAR.

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in
  • What links here
  • Related changes
  • Special pages
  • Printable version