-
Notifications
You must be signed in to change notification settings - Fork 20
Converting to FastBasic
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.
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.
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
GOTO
, GOSUB
, RETURN
, RESTORE
, READ
, ON
(variable) (GOTO
, GOSUB
, EXEC
). PAINT
, TEXT
, RAND
- When
GOTO
is used for a loop, replace withDO
-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, removeTHEN
and COLONs and add anENDIF
after where the last statement was on the line. FastBasic only skips the first statement following theTHEN
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
GOTO
s. If this creates a loop until condition, replace withREPEAT
UNTIL
(opposite condition) orWHILE
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 anENDIF
when theGOTO
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
passRETURN
with anotherRETURN
... ReplaceRETURN
withEXIT
and lastRETURN
withENDPROC
or useIF
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
Before deleting line numbers, need to find any GOSUB
s 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.