bas7advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CLEAR Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Reinitializes all program variables, closes any open files, and optionally
sets the stack size.
 
CLEAR [,,stack&]
    ■ The argument stack& sets aside stack space for your program. BASIC
      takes the amount of stack space it requires, adds the number of bytes
      specified by stack&, and sets the stack size to the result.
    ■ Two commas are used before stack& to keep BASIC compatible with BASICA.
      BASICA included an additional argument that sets the size of the data
      segment. Because BASIC automatically manages the data segment, the
      first parameter is no longer required.
 
Usage Notes
    ■ The CLEAR statement:
      Closes all files and releases the file buffers.
      Clears all common variables.
      Sets numeric variables and arrays to zero.
      Sets all string variables to null.
      Reinitializes the stack and, optionally, changes its size.
    ■ If your program has deeply nested subroutines or procedures, or if
      you use recursive procedures, you may want to use a CLEAR statement
      to increase the stack size. You may also want to increase the stack
      size if your procedures have a large number of arguments.
    ■ Clearing the stack destroys the return addresses placed on the
      stack during a GOSUB operation. This makes it impossible to execute
      a RETURN statement correctly and BASIC generates a "RETURN without
      GOSUB" run-time error message. If you use a CLEAR statement in a
      SUB or FUNCTION, BASIC generates the run-time error message,
      "Illegal function call."
 
Differences from BASICA
    ■ BASICA programs using CLEAR may require modification. In BASICA
      programs, any DEF FN functions or data types declared with DEFtype
      statements are lost after a CLEAR statement. In compiled programs,
      this information is not lost because these declarations are fixed at
      compile time.