This is a shareware program copyright 1987 by George Trepal. It's OK to distribute this program free, or in the case of computer clubs or similar groups to charge a small copying fee, but it's not legal to sell it. If you feel it's useful enough to be worth something then I'll happily accept contributions. George Trepal, 2650 Alturas Road, Bartow, Florida 33830 USA.
This program helps to convert Basic programs written on other computers to AmigaBASIC. It deletes line numbers, puts in its own jump labels, and tries to format the result as a structured program. It also breaks down lines with multiple commands. Really weird coding will confuse it but it works about 99% of the time and can save you lots of time and energy.
To use it the alien Basic has to be in the form of an ASCII file. Most computers let you save Basic as ASCII with no hassle. There are a few you need to be creative about such as the Commodore 64.
Next you have to see if all the commands are run together. Some Basics allow that and you'll see something like:
100 FORJ=1TO50:PRINT"POO":NEXT (not a space in the line)
AmigaBasic can't handle stuff like this. All Basic Command words have to be set off with spaces. Use the global change of a word processor, editor, microemacs, or whatever to fix the problem. You'll now have:
100 FOR J=1 TO 50:PRINT "POO":NEXT
Now load the program into AmigaBasic then save it from AmigaBasic by SAVE "filename",a
What this does is capitalize all the command words so my program can find them. Saving with comma A forces the computer to write an ASCII file.
Finally it's time to run my program. Look at the before and after examples below.
(By the way, this code does nothing it's just a test fragment.)
BEFORE:
100 FOR j = 1 TO 5: PRINT "Whee":NEXT
110 IF x = 3 THEN y=3:p=4:G=4:GOTO 200
115 G = 1
120 q = Z:r = M:l=6: GOTO 1100
130 GOSUB 500
140 ON x GOTO 200, 300, 400
200 PRINT "200"
210 END
220 :
300 PRINT "300"
310 END
400 PRINT "400"
410 END
500 INPUT x
510 RETURN
610 IF p = 2 THEN l = 7: p = 3: GOSUB 300
620 GOSUB 1100
630 IF t = 5 THEN 300
640 IF t = 6 THEN l = 5
1100 IF x = 1 THEN FOR j = 1 TO 6: p = q: NEXT
Here's what it looks like after it's been run through the mill.
AFTER:
FOR j = 1 TO 5
PRINT "Whee"
NEXT
IF x = 3 THEN
y=3
p=4
G=4
GOTO Jump1
END IF
G = 1
q = Z
r = M
l=6
GOTO Jump5
GOSUB Jump4
ON x GOTO Jump1, Jump2, Jump3
Jump1:
PRINT "200"
END
Jump2:
PRINT "300"
END
Jump3:
PRINT "400"
END
Jump4:
INPUT x
RETURN
IF p = 2 THEN
l = 7
p = 3
GOSUB Jump2
END IF
GOSUB Jump5
IF t = 5 THEN Jump2
IF t = 6 THEN l = 5
Jump5:
IF x = 1 THEN
FOR j = 1 TO 6
p = q
NEXT
END IF
There's a quirk of AmigaBasic you have to watch out for. Consider this alien Basic fragment:
100 FOR J = 1 TO 20
110 IF L > P THEN GOTO 130
120 R = S
130 R = T
140 NEXT
When my program gets hold of this it becomes
FOR J = 1 TO 20
IF L > P THEN GOTO Jump1
R = S
Jump1:
R = T
NEXT
It looks nice but AmigaBasic won't run it. It won't allow a label in a FOR-NEXT loop and you'll next a For Without Next or Next Without For error.
The solution? Clean up the code.
FOR J = 1 TO 20
IF L > P THEN R = S ELSE R = T
NEXT
In case you need to get ASCII from a C-64 here's how. Load the Basic program in the C-64. To save it as ASCII you tell the computer:
OPEN 8,8,8,"filename,S,W": CMD 8: LIST
then after the drive no longer makes noise you tell it:
PRINT#8," ": CLOSE 8
The first part of the first line opens a sequential file to be output to device number 8 (the disk drive.) The second part directs all output to device number 8. When you tell it to list the list, in ASCII, goes to the drive instead of the screen or printer.
The first part of the second line clears the drive's buffer thus making sure you have all your file on disk.
Complex but it works. If a C-64 can be made to output ASCII files I think any computer can be made to output them.