Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CLEAR command
#2
(02-02-2024, 10:13 PM)bartok Wrote: Hi, I need an explanation about the command "CLEAR".

DIM a% locates a part of memory for the variable a%, that is empty.

a%=1 give to the variable a% the value 1.

What does CLEAR? Does it makes a% empty again, or does it deletes the memory located for a%, virtually "deleting" the command DIM a%?
CLEAR erases the values within variables. The variables still exist they are just nulled or set to zero.

Dynamic arrays (REDIM) are completely removed however and will need to be redimensioned after a CLEAR statement. The code below shows the different behaviors.

Code: (Select All)
OPTION _EXPLICIT

DIM a%
DIM s$

REDIM b%(20)

a% = 1
s$ = "Test"
b%(20) = 2
PRINT a%
PRINT s$
PRINT b%(20)
CLEAR
PRINT a% ' a reset to 0
PRINT s$ ' reset to null
'PRINT b%(20) ' if you activate this line you'll get an error
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
CLEAR command - by bartok - 02-02-2024, 10:13 PM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 02:53 AM
RE: CLEAR command - by bartok - 02-03-2024, 09:52 AM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 04:35 PM
RE: CLEAR command - by bartok - 02-03-2024, 09:11 PM
RE: CLEAR command - by bartok - 02-03-2024, 02:48 PM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 04:29 PM
RE: CLEAR command - by bartok - 02-03-2024, 06:26 PM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 05:22 PM
RE: CLEAR command - by bartok - 02-03-2024, 06:16 PM
RE: CLEAR command - by SMcNeill - 02-03-2024, 06:32 PM
RE: CLEAR command - by bartok - 02-03-2024, 08:20 PM
RE: CLEAR command - by SMcNeill - 02-03-2024, 10:24 PM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 10:55 PM
RE: CLEAR command - by bartok - 02-04-2024, 09:56 AM
RE: CLEAR command - by bplus - 02-03-2024, 06:41 PM
RE: CLEAR command - by TerryRitchie - 02-03-2024, 06:48 PM
RE: CLEAR command - by SMcNeill - 02-04-2024, 12:17 PM
RE: CLEAR command - by bartok - 02-04-2024, 01:13 PM
RE: CLEAR command - by Dimster - 02-04-2024, 03:26 PM
RE: CLEAR command - by bplus - 02-04-2024, 04:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Command$(count%) - I can't get a value when using the optional argument "(count%)" Unatic 3 530 08-22-2025, 11:58 AM
Last Post: Unatic
  keyword to get the EXE name and the EXE path instead of parsing Command$(0) ? madscijr 8 1,159 07-22-2025, 08:35 PM
Last Post: hsiangch_ong
  Command$ issues eoredson 8 1,409 05-02-2025, 01:42 AM
Last Post: eoredson
  Locate command on the ttf graphical screens Helium5793 5 726 03-09-2025, 05:47 PM
Last Post: SMcNeill
  The Locate command eoredson 0 445 04-13-2024, 06:27 AM
Last Post: eoredson

Forum Jump:


Users browsing this thread: 1 Guest(s)