Was there ever a first parameter for the CLEAR statement?
Asked Answered
T

1

5

In both GW-BASIC and QuickBASIC, statements are passed arguments, some of which are optional and can be omitted depending on the statement:

REM Move the text cursor to the specified column and row.
LOCATE row%, column%

REM Move the text cursor to the specified column without changing the row.
LOCATE , column%

In GW-BASIC, the CLEAR statement is rather unusual in that its first "argument" is always omitted:

CLEAR , basicMem
CLEAR , basicMem, basicStack
CLEAR , , basicStack

In QuickBASIC, the basicMem parameter became optional due to the interpreter/runtime managing its own memory:

CLEAR , , basicStack

What I'm wondering is whether that first "argument" ever used for anything prior to GW-BASIC, i.e. something like this was actually useful:

CLEAR missingArg, basicMem, basicStack
REM   ^^^^^^^^^^
REM      here

That is, was there ever an purposeful non-empty argument before the first comma?

If anybody has any idea, I'd love to know!

Tother answered 8/12, 2018 at 6:48 Comment(2)
You piqued my curiosity and I spent quite a bit of time trying to search to find out about this anomaly. It is strange that you can have zero, one, or three parameters (with the first skipped) only, and not two. Consider posting this (not cross-posting but re-posting) in Retro Computing where there might be some who have insight on this.Serriform
@BillHileman If you're interested in an answer, I posted one here with links to manuals on archive.org. It at least goes all the way back to 8K BASIC for the Altair 8800, and it might go further back, but that is where I stopped looking for answers.Tother
T
7

What I'm wondering is whether that first "argument" ever used for anything prior to GW-BASIC, i.e. something like this was actually useful:

CLEAR missingArg, basicMem, basicStack
REM   ^^^^^^^^^^
REM      here

That is, was there ever an purposeful non-empty argument before the first comma?

Yes, there was a first argument, but there was never a 3-argument form that actually made use of it.

Microsoft (originally Micro-Soft) created Altair BASIC. It featured a CLEAR command with no arguments that set all program variables to zero. The 4K version had no strings, so it had no need for managing string space. However, the 8K, Extended, and Disk versions had a CLEAR command that also accepted a single argument of the form CLEAR x. The value x specified the maximum amount of string space available in bytes, with the default at load time of BASIC being 50 bytes in the 8K version and 200 bytes in the Extended and Disk versions until it was changed [source]. That's where the missing first argument came from and what it was used for originally. At the time, however, only that one argument was valid.

Microsoft went on to develop a derivative called "BASIC-80" for several systems, notably the Intel ISIS-II, CP/M, and TEKDOS operating systems. A "Standalone Disk BASIC" version of BASIC-80 was also created that could run on "almost any 8080 or Z80 based disk hardware without an operating system." There was no 4K version of BASIC-80, so it's reasonable to assume all versions of BASIC-80 had strings available as the 8K version of Altair BASIC did. As a result, that string space needed managed. However, it was in BASIC-80 that a second argument was added:

CLEAR [expression![,address]]

expression! was an expression that specified the amount of string space, like in 8K (Altair) BASIC, and address was the maximum address available to BASIC, i.e. the amount of memory available to BASIC, like the argument immediately after the first comma in GW-BASIC.

Eventually, BASIC-80, Release 5.0, was shipped into the world, and it featured the odd syntax instead:

CLEAR [,[expression1][,expression2]]

expression1 was the maximum memory available to BASIC, and expression2 was the amount of stack space. Appendix A: New Features in BASIC-80, Release 5.0 explains why the first argument was dropped:

  1. String space is allocated dynamically, and the first argument in a two-argument CLEAR statement will be ignored.

In other words, CLEAR strSpace!,maxMem would ignore the strSpace! argument in BASIC-80, Release 5.0, so the syntax became CLEAR [,[maxMem][,maxStack]].

QuickBASIC eventually changed the syntax further to just CLEAR [,,stack]. Confusingly, the on-line help system of QuickBASIC 4.5 states the following:

 Note: Two commas are used before stack to keep QuickBASIC compatible
       with BASICA. BASICA included an additional argument that set the
       size of the data segment. Because QuickBASIC automatically manages
       the data segment, the first parameter is no longer required.

"The first parameter" mentioned is maxMem as BASICA (and GW-BASIC) used the syntax available with BASIC-80, Release 5.0, rather than the equally missing strSpace! parameter used by pre-5.0 releases of BASIC-80.

Tother answered 11/12, 2018 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.