Structured SuperBASIC

See all articles from CATS v8 n4
Author(s): Tim Swenson
Publication: CATS Newsletter
Pub Details: CATS v8 n4 (Volume 8, Issue 4)
Date: September 1990
Pages: 4

Structured SuperBasic (SSB) is my attempt solve a problem that has plagued me. After programming in C and Pascal for a while I found that SuperBasic listings were not as easy to read as I would like. There was no white space between blocks of code to separate them. The line numbers clouded things up. I know there had to be a better way. I had seen how the new MS-DOS Basics looked and liked the use of no line numbers.

Not being in the mood to write a SuperBasic compiler of my own, I had to come up with a better idea. I concieved a program that would “translate” SSB programs into a form that SuperBasic could handle. Well, here it is. This is just the bare bones program. I plan to work on it some more, add bells and whistles, etc. I do plan to write up some better documentation and compile the program for speed. Let me know what you think and tell me about any changes you would like.

The Structured SuperBasic Converter program takes a program written in SSB form and converts it into a SuperBasic program will all the line numbers. Since line numbers are not used in SSB, labels are used for GOTO and GOSUB statements.

The best way to really describe SSB is to show you a SSB program.

    ## Sample Structured SuperBasic
Program

x = 1
@loop
print x

if x > 30 then
print "End"
print "of"
print "Program"
stop
end if

goto @loop

## End of Program

Yes, this is a do nothing program, but it shows you how SSB looks. A ## is used to mark a comment line. This line is converted to a REMark line in SuperBasic. The @ sign is used to distinquish a label. The @ sign must be in the 1st character position to mark the label. The label will mark the next line as the place to GOTO.

The greatest feature is the use of white space to break up the code into readable blocks. This allows the code to be easier to read.

When you use the converter program, you supply it with the input file (your SSB program) and the output file (your SuperBasic program). The output file must not exist. The converter will run through the program in two passes. When it is done, the output file is ready to be loaded and run in SuperBasic.

The convertor program does not check your syntax of your program. If you do have a syntax error, you will see the keywork MIStake in your program when you load it.

The converter does have some limitations. You must not use an @ sign or ## in your program. The labels must be in the same case. @loop is not the same as @LOOP. You must have at least one space before each line (except labels).

Even with these limitatins, SSB can be usefull. Read over the program to see how it works.

If you have any questions, please give me a call (I’m listed on the back of the Newsletter).

SSB_BAS

100 CLS
110 REMark Init Variables
120 DIM label$(30,10)
130 DIM label(30)
140 label_var = 1
150 line_num = 100
160 INPUT "Enter input file:
";in_file$
170 INPUT "Enter output file:
";out_file$
180 PRINT "PASS 1"
190 OPEN_IN #4,in_file$
200 REPeat pass_1
210 INPUT #4,in$
220 IF EOF(#4) THEN EXIT pass_1
230 IF LEN(in$)=0 THEN END REPeat
pass_1
240 IF in$(1)="@" THEN
250 label$(label_var) = in$
260 label(label_var) =
line_num
270 label_var = label_var + 1
280 ELSE
290 line_num = line_num + 10
300 END IF
310 END REPeat pass_1
320 CLOSE #4
330 PRINT "PASS 2"
340 LET line_num = 100
350 OPEN_IN #4,in_file$
360 OPEN_NEW #5,out_file$
370 REPeat pass_2
380 INPUT #4,in$
390 IF EOF(#4) THEN EXIT pass_2
400 IF (LEN(in$)=0) OR
(in$(1)="@") THEN END REPeat
pass_2
410 REMark remarks
420 LET temp = "##" INSTR in$
430 IF temp<>0 THEN
440 PRINT #5,line_num;" remark
";in$(1 TO temp-1);in$(temp+2
TO )
450 ELSE
460 REMark Labels
470 LET temp= "@" INSTR in$
480 IF temp<>0 THEN
490 a$ = in$(temp TO )
500 temp2 = 0
510 temp2 = temp2 + 1
520 IF label$(temp2) <> a$
THEN GO TO 510
530 PRINT #5,line_num;in$(1
TO temp-1);label(temp2)
540 ELSE
550 PRINT #5,line_num;in$
560 END IF
570 END IF
580 LET line_num = line_num + 10
590 END REPeat pass_2
600 CLOSE #4
610 CLOSE #5
620 PRINT "Program Done"

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.