1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-03 15:51:20 +00:00
QB64-PE/internal/help/CLEAR.txt

38 lines
1.4 KiB
Plaintext
Raw Normal View History

The ''CLEAR''' statement clears all variable and array element values in a program. It does not affect constant values!
2016-03-18 11:36:04 +00:00
''Syntax:'' '''CLEAR''' [, ''stacksize&'' , ''stackspace&'']
{{PageDescription}}
2016-03-18 11:36:04 +00:00
* 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 [[Arrays|array]] values where numerical values become zero and string values become null.
* It does not clear [[CONST|constant]] values.
* Closes all opened files also.
2016-03-18 11:36:04 +00:00
* [[$DYNAMIC]] or [[REDIM]] arrays will need to be [[REDIM|re-dimensioned]] or an [[ERROR Codes|error]] will occur when referenced because it was removed.
2016-03-18 11:36:04 +00:00
''Example:'' Using CLEAR to clear array elements from [[STATIC|static]] arrays or arrays created using [[DIM]].
{{CodeStart}} '' ''
{{Cl|CLS}}
{{Cl|DIM}} array(10) 'create a {{Cl|$STATIC}} array
array(5) = 23
{{Cl|PRINT}} array(5)
{{Cl|CLEAR}}
{{Cl|PRINT}} array(5) '' ''
{{CodeEnd}}
:''Note:'' If you change DIM to REDIM a "Subscript out of range" error will occur because a [[$DYNAMIC]] array is removed by CLEAR.
{{PageSeeAlso}}
2016-03-18 11:36:04 +00:00
* [[ERASE]] {{text|(array names only)}}
* [[REDIM]] {{text|(array sizes only)}}
* [[_PRESERVE]] {{text|(REDIM arrays only)}}
* [[Arrays]], [[&B|_BIT arrays]]
{{PageNavigation}}