BASIC's question mark and PRINT

Jim Battle frustum at pacbell.net
Mon Nov 21 14:26:52 CST 2005


Allison wrote:

>>Subject: Re: BASIC's question mark and PRINT
>>  From: Jim Battle <frustum at pacbell.net>
>>  Date: Mon, 21 Nov 2005 13:03:31 -0600
>>    To: General Discussion: On-Topic and Off-Topic Posts <cctalk at classiccmp.org>
>>
>>tim lindner wrote:
>>
>>>In BASIC, where did the short cut of '?' for PRINT originate?
>>>
>>>After following a discussion on the CoCo list I thought I'd ask here.
>>>
>>
>>Here are some bounds and data points.
>>
>>The Dartmouth BASIC specification does not have ? as an abbrevation (circa 1964).
>>
>>I think all versions of Microsoft BASIC have this shortcut (circa 1975).
>>
>>Palo Alto Tiny BASIC (li chen wang) didn't use this convention -- instead it 
>>used "P.".
>>
>>Wang BASIC (circa 1972) didn't use this convention.
>>
>>From what I can tell, DEC BASIC didn't use this abbreviation.
> 
> 
> The ? was adopted by convention from the fact that early MS basic 
> (MITS BASIC) the ? was also the same value as the token for print.
> Most of the non-compiled 8bit basics were tokenized in memory for 
> execution and storage and when "LIST"ed were detokenized to list as 
> Basic we know.
> 
> Allison

Allison, that seems unlikely.  Later versions of microsoft basic certainly 
didn't use any value lower than 0x80 for tokens.  Even if you could find a few 
characters in the "live" portion of the ascii table that didn't lead to 
ambiguous parsing, I can't think of a good reason why they'd do it -- there was 
enough room at 0x80 and above, and not enough unused values below 0x80, so why 
have two lookup tables when one would do?

It would seem much easier to have special case where '?' got mapped to the token 
for PRINT.

OK, trying to be less speculative, I looked at the binary for

	ALTAIR BASIC VERSION 3.2 [EIGHT-K VERSION]

that is included with Rich Cini's Altair emulator.  At the end is the list of 
the statement keywords.  In memory each keyword abuts the next, and the boundary 
between keywords is marked by setting the msb of the byte.  Here is the table in 
order:

END
FOR
NEXT
DATA
INPUT
DIM
READ
LET
GOTO
RUN
IF
RESTORE
GOSUB
RETURN
REM
STOP
OUT
ON
NULL
WAIT
DEF
POKE
PRINT
CONT
LIST
CLEAR
CLOAD
CSAVE
NEW
TAB(

Since there no room for storing a token value after each item (I know it is 
possible that that mapping is held elsewhere, but it seems unlikely), these 
keywords very likely have consecutive token values.

Elsewhere in the binary, near the beginning, is a similar table for the 
functions (FN, SPC, NOT, AND, OR, VAL, CHR, LEFT, RIGHT, MID, FRE, SIN, COS, 
TAN, PEEK, etc, but also including THEN, STEP).




More information about the cctalk mailing list