Language features of Stefan's BASIC as compared to Dr. Wang's Palo Alto BASIC, Apple 1 BASIC, and Dartmouth BASIC - slviajero/tinybasic GitHub Wiki

Stefan's BASIC implements the full language definitions of the legendary Palo Alto BASIC from 1976 Dr. Dobbs Magazine and the full Apple Integer BASIC . Features of Microsoft BASIC were added where it made sense. Most of the Dartmouth language set plus some additional add ons have been implemented. Some ECMA Basic features made it into the code.

The interpreter now is structured in language sets that can be compiled in individually on top of the Palo Alto core.

Please consult the full manual for the documentation of the language.

Palo Alto BASIC Language set

PRINT, LET, INPUT, GOTO, GOSUB, RETURN, IF, FOR, TO, NEXT, STOP, LIST, NEW, RUN, ABS, RND, SIZE, REM, 26 static Variables A-Z, @() as a rest of memory array

Apple Integer BASIC add ons

NOT, AND, OR, LEN, SGN, PEEK, DIM, CLR, HIMEM, TAB, THEN, POKE, dynamic variables A-Z[0-9,A-Z], strings A-Z[0-9,A-Z], arrays A-Z[0-9,A-Z], optionally two dimensional arrays and one dimensional string arrays. Strings of arbitrary length. (Apple Integer BASIC originally did not have two letter variables and arbitrary length string, this implementation has).

Stefan's add ons

ELSE, SQR, MAP, DUMP, SAVE, LOAD, GET, PUT, SET, POW, string names A-Z[0-9,A-Z], @E() EEPROM array, @$ string, INT, special variables @D(), @X, @Y for display access, @C as GET synonym for the default character stream, @S as error status. @T$ and @T() for real time clock access. CONT to continue loops, BREAK to end them.

Arduino I/O add on

AWRITE, AREAD, DWRITE, DREAD, PINM, DELAY, MILLIS, PUSLE, PLAY, MAP

Floating point add ons

SIN, COS, TAN, ATAN, EXP, LOG

DARTMOUTH BASIC add ons

DATA, READ, RESTORE, ON .. GOTO/GOSUB, DEF FN A-Z[0-9, A-Z]

Graphics for TFT displays

COLOR, PLOT, LINE, RECT, FRECT, CIRCLE, FCIRCLE

(look here for more on graphics and the TFT display)

DARKARTS add ons - things that don't really belong into a BASIC

EVAL, MALLOC, FIND, CLR variable

IoT addons

OPEN and CLOSE open Wire, RF2401, and MQTT connections. AVAIL to check the streams. Network functions are controlled by NETSTAT, Wifi and Ethernet implemented, simple unencrypted MQTT. SLEEP for ESP8266, ESP32 and Arduino SAMD (with RTCZero library). INSTR, VAL and STR to handle string data.

Timers, interrupts and errors

Two timers can be used with the EVERY and AFTER command. Interrupts are handled with the EVENT command. Errors can be trapped with the ERROR command while I/O exceptions are handled through the status variable @S.

File system commands

OPEN, CLOSE, DELETE, CATALOG, FDISK

Multidim arrays and string arrays

If the HASMULTIDIM option is set, arrays can be two dimensional. HASSTRINGARRAYS adds 1d string arrays to the code.

Structures programming extension

WHILE, WEND, REPEAT, UNTIL are implemented now in a first version. An experimental SWITCH, CASE statement similar to C is added as well. DO and DEND can group statements for multi line IF.

Multiline functions

DEF FN type function statements can be extended to multiline functions using a DEF FN : RETURN value : DEND construct.

Main differences to Palo Alto BASIC

  • # is replaced by <>.
  • (Almost) all commands can be executed interactively.
  • LOAD and SAVE are present even in the minimal language set for EEPROM storage.
  • RND starts at 1 on Palo Alto and at 0 in IoT BASIC.
  • The memory array @ starts at 0 in Palo Alto BASIC and at 1 at IoT BASIC.

Main differences to Apple Integer BASIC

  • # is replaced by <>.
  • The AUTO and DEL editor commands are not implemented (yet).
  • HIMEM is constants but cannot be assigned, LOMEM is removed.
  • String variables can be two letter like arrays and conventional variable.
  • Apple integer BASIC had an odd feature. Using an array or string variable without subscripts would evaluate to the first element of the object. This has been removed.
  • Strings autocreate to size 32 if not dimensioned conforming with ECMA standard
  • Arrays autocreate to size 10 if not dimensioned conforming with ECMA standard
  • Number arrays can be 2d.
  • Variable names can be two letters (was not there in Apple 1 but later yes)

Compatibility settings

BASIC tries to be compatible to Apple 1 BASIC. There are minor differences between Palo Alto BASIC, Apple 1 BASIC and MS type BASICs like the one on a C64. The differences are the lower index of the array, the lower index of random and display of integer numbers. The SET command can be used

Concepts taken over from one of the two which are unusual for a modern BASIC interpreter

  • The @() array from Palo Alto has been ported. This array allows access to the free memory as one big array.
  • Steve Wozniak's string and substring syntax has been implemented (see the Apple 1 manual for details). It is an elegant way of dealing with strings at the price of making string arrays impossible.
  • The TAB statement has been implemented from Apple Integer BASIC to print tables. It is a command and not a part of PRINT like in other dialects.
  • GOTO LINENUMBER switches on RUN mode.

Addons which are neither in Palo Alto nor in Apple 1 BASIC are

  • MAP() is the ARDUINO map functions.
  • PEEK and POKE for negative values access the EEPROM.
  • SQR() calculates an integer square root.
  • Arduino I/O functions implemented.
  • @$ is a string variable containing the input buffer.
  • @E() is an array accessing the EEPROM of an Arduino as one single array just like @() does on Palo Alto BASIC.
  • @E is the size of the EEPROM, just like SIZE for regular memory
  • many special variables like @T() for the clock, @C and @A for the input stream, @D as a display buffer access method
  • BREAK to end loops, CONT to continue them.
  • @S is a general purpose status variable.
  • AFTER and EVERY timer can be used to change the program flow. This features is taken from Locomotive BASIC.
  • ERROR traps errors. Also a feature from Locomotive BASIC.
  • After VAL(), @V contains the number of bytes processed. This is Arduino parseint implemented to BASIC.

Features changing Dartmouth language behaviour

  • When READ has read the last DATA item the next READ always returns 0 and @S is set to 1. No error is thrown.
  • RESTORE can have the data item index as an argument.
  • DATA is a variable and returns the active data item index.
  • Dartmouth also has ELSE which was never part of the Dartmouth standard BASIC.
  • ELSE can be on a separate line after IF.

Features from other BASIC dialects

  • The stream mechanism using I/O streams is taken from Locomotive BASIC on the Amstrad CPC computers.

ECMA BASIC standards

Among the forgotten things around BASIC is the ECMA standard of a minimal BASIC from 1978
ECMA55(https://github.com/slviajero/tinybasic/blob/main/misc/ECMA-55_1st_edition_january_1978.pdf). It was am effort to generate a standard BASIC when Microsoft had already set the de facto standard. I still find the document interesting. My BASIC implements the ECMA 55 standard with the following exceptions.

  • Arrays can be one or two dimensional.
  • Arrays start at 1. The OPTION BASE mechanism is implemented as SET command to start the indexing at 0.
  • String variable initialize to a fixed length of 32 and not 18.
  • Error handling is much more tolerant than the ECMA standard recommends.

There is a newer standardECMA116(https://www.ecma-international.org/wp-content/uploads/ECMA-116-1st-edition-June-1986.zip) which contains quite a few interesting idea as well.