Skip to content

Converting to FastBasic

Kim Slawson edited this page Mar 26, 2021 · 3 revisions

This documents what is known to date about converting Basic programming on Atari 8-bit machines, 400/800/XL/XE, XEGS. Includes versions Atari Basic, Turbo Basic XL, Basic XL, and Basic XE to Fast Atari Basic. Many of the programs that are usual to convert are written in the original Atari Basic, or Turbo Basic XL, OSS Basic XL / XE. Written before the conventions of Structured Programming became wide spread. Atari Basic does not have ELSE, ELSEIF, ENDIF, DO LOOP, WHILE WEND, REPEAT UNTIL structures.

Extracting the program code.

Use the LIST (filename)command in AtariBasic to files to disk in a separate ATR in the emulator. Then use an Atari Disk Utility to extract the files to my PC hard drive.

I discovered it is good to use a good Text Editor on your PC. I have been using “PSPAD” and know people using Visual Studio Code. I have not had time to make up a syntax file for each of these programs. It does help if your editor has a rectangle block text select as you need to removing line numbers at some point.

Variable Usage

A variable name has to be unique and cannot be the same for being used for 2 or more than one type. Cannot have A$, A%, and A in the same program. Variables should be set to their default value at the beginning of the program before any usage. Data Tables and Arrays must be declared at the beginning of the program before any executable code

Commands No Longer Supported and their equivalent constructs

GOTO, GOSUB, RETURN, RESTORE, READ, ON (variable) (GOTO, GOSUB, EXEC). PAINT, TEXT, RAND

  • When GOTO is used for a loop, replace with DO-LOOP.

Replace:

10 ? “HELLO”
20 GOTO 10

With:

DO
  ? “HELLO”
LOOP
  • IF THEN followed by multiple statements separated with COLONs (:) need to placed on separate lines, remove THEN and COLONs and add an ENDIF after where the last statement was on the line. FastBasic only skips the first statement following the THEN if the condition is false.

Replace:

A = 0
IF X THEN A=1 : X = 0 : ? “TEST”

With:

IF X
  A = 1
  X = 0
  ? “TEST”
ELSE
  A = 0
ENDIF
  • IF THEN GOTOs. If this creates a loop until condition, replace with REPEAT UNTIL (opposite condition) or WHILE WEND.

Replace:

10 A=10
20 ? "Line "; A
30 A=A-1
40 IF A > 0 THEN GOTO 20

With:

A=10
REPEAT
  ? “Line “;A
  A=A-1
UNTIL A<=0
  • IF THEN GOTO bypass a chunk of code, test of opposite condition, and place an ENDIF when the GOTO destination was.

The program should be converted to the conventions of structured programming.

IF (Condition) THEN RETURN, or ENDPROC, Use, IF (Condition) THEN EXIT

Replace:

10 A=1
20 GOSUB 100
30 END
100 ? “Procedure “; A
110 IF A < 0 THEN RETURN
120 ? “OK”
130 RETURN

With:

A=1
EXEC Example
END
PROC Example
  ? “Procedure “; A
  IF A<0 THEN EXIT
  ? “OK”
ENDPROC
  • IF (Condition) THEN GOTO pass RETURN with another RETURN... Replace RETURN with EXIT and last RETURN with ENDPROC or use IF ELSE ELIF ENDIF structure.

Replace:

10 A=1 : GOSUB 100
20 A=2 : GOSUB 100
30 END
100 ? “Proc “;A
110 IF A=1 THEN 140
120 ? “A=”;A
130 RETURN
140 ? “SKIP”
150 RETURN

With:

A=1 : EXEC Tst
A=2 : EXEC Tst

PROC Tst
  ? “Proc “;A
  IF A<>1
    ? “A=”;A
    EXIT
  ENDIF
  ? “SKIP”
ENDPROC

Line Numbers.

Before deleting line numbers, need to find any GOSUBs and the line number destination. Easiest thing to do is just create a name for the new PROC, or just put a letter + underscore + line number. Line 1000 becomes PROC S_1000 and replace the Return with ENDPROC. Also may need to use the editor’s FIND + REPACE function if there are many calls to the subroutine. You can give the subroutine a more descriptive name after the program is working.

Clone this wiki locally