Copyright 1984 by ABComputing ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ MetaBASIC REVIEW ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ Reviewed by Bill Salkin ³ ³ ³ ³ Product Name MetaBASIC ³ ³ Description Structured BASIC preprocessor ³ ³ ³ ³ Overall Rating Very good ³ ³ ³ ³ Company Name Software 128 ³ ³ Address 363 Walden Street, Concord, MA 01742 ³ ³ (617) 369-6400 ³ ³ ³ ³ Version 1.0 ³ ³ Price $75 ³ ³ Copy protected No ³ ³ RAM needed 64K ³ ³ DOS level 1.0, 1.1, 2.0 ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ MetaBASIC REVIEW ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ Manual Well written. Needs more sample programs ³ ³ illustrating MetaBASIC features. ³ ³ ³ ³ Unusual 1. Combination of features taken from other ³ ³ Features languages ( PASCAL, FORTRAN, BASIC ). ³ ³ 2. Allows for separate subroutines with ³ ³ calling sequences and argument lists. ³ ³ ³ ³ Omissions Does not present full set of standard structures. ³ ³ "DO CASE" is missing ( though the equivalent ³ ³ IF..ELSEIF..ELSEIF..ELSE is present). "Repeat ³ ³ until" structure is also missing. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ MetaBASIC REVIEW ³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ³ ³ ³ ³ Comments Reasonably fast when done on RAM disk. ³ ³ MetaBASIC uses many intermediate files ³ ³ so RAM disk is the best approach. ³ ³ ³ ³ Code generated is compatible with the ³ ³ BASIC compiler. ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Introduction ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ MetaBASIC ( abbreviated MB ) is a BASIC preprocessor that converts structured MetaBASIC code into standard BASIC. A MetaBASIC program consists of standard BASIC keywords, and special MetaBASIC constructs. A tilde "~", or equivalently the word META, differentiates standard BASIC commands from METABASIC commands. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Data Initialization Structures ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ MB has borrowed heavily from other languages. The data initialization method is borrowed from FORTRAN, and uses the ~DATA ( read MetaDATA ) statement. For example, to set the variable PI equal to 3.14159 the MB statement is ~DATA PI/ 3.14159/ and to set X,Y,Z to 0 use: ~DATA X,Y,Z / 3*0 / ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Record Structures ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The record structures are borrowed from Pascal. The following example defines a METArecord SHOES and initializes the members in this record. ~RECORD SHOES (BROWN,WHITE,GREEN) SHOES.BROWN = 1 SHOES.WHITE = 3 SHOES.GREEN = 2 The MB manual assumes that you are somewhat familiar with these types of constructs, as the examples given in the user manual are not sufficiently good for novices. The manual is otherwise, very well written and readable. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Separate Compilation ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Separate subroutines with calling sequences are sup- ported. For example, the statement ~CALL MESSAGE( "HELLO") (in file MAIN.BAS ) calls the subprogram MESSAGE ( in file MESSAGE.BAS) to display the string "HELLO". To convert the MetaBASIC source file "MAIN.BAS" to standard BASIC type A>mb MAIN; and press the ENTER key. The following is displayed: MetaBASIC, Version 1.0 (c) Copyright 1983, SOFTWARE 128 Processing Main Program File: MAIN.BAS Processing Subprogram File: MESSAGE.BAS A> Notice that subprograms are searched for automatically by the MB preprocessor. The preprocessor generates a "hash" or composite file containing standard BASIC which runs under the BASIC interpreter. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Cross-reference ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ If the BASIC interpreter reports an error in a composite file the user need not examine the composite code to determine the source of the error. Instead, exit BASIC, invoke the cross-reference program and key the line number of the error reported by the interpreter. The cross-reference program returns the name of the MetaBASIC file, and the line number in this file of the corresponding statement. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Error-handling ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ The error messages displayed by either processor are clear and coherent. ( This is fortunate as the manual lacks an ERROR MESSAGES section.) Occasionally an error may generate a flurry of spurious messages. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Examples ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ This review closes by examining samples of code generated by the MB preprocessor. I do not claim these are the best or worst examples one could use. The following examples also show that MetaBASIC source code does not require line numbers. ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Example 1: Input ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ~DATA PI/ 3.14159/ ³ ³ ~DATA X,Y,Z / 3*0 / ³ ³ ³ ³ OPTION BASE 1 ³ ³ DIM SALES(6) ³ ³ ~DATA SALES() / 1,2,3,4,5,6/ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÛÛÛ MB preprocessor ³ v Output ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ 1 DIM A..#(00000),A..%(00000),A..!(00005),A..$(00000) ³ ³ 2 AAA!=3.14159 ³ ³ 4 BAA!=0 ³ ³ 5 CAA!=0 ³ ³ 6 DAA!=0 ³ ³ 11 N%=0:FOR I%=0 TO 5: ³ ³ 12 N%=N%+1 ³ ³ 13 IF N%>=1 AND N%<2 THEN A..!(I%)=1 ³ ³ 14 IF N%>=2 AND N%<3 THEN A..!(I%)=2 ³ ³ 15 IF N%>=3 AND N%<4 THEN A..!(I%)=3 ³ ³ 16 IF N%>=4 AND N%<5 THEN A..!(I%)=4 ³ ³ 17 IF N%>=5 AND N%<6 THEN A..!(I%)=5 ³ ³ 18 IF N%>=6 AND N%<7 THEN A..!(I%)=6 ³ ³ 19 NEXT: ³ ³ 21 END ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Very peculiar code, particularly lines having the form (IF N% >=1 and N% < 2 ). ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Example 2: In this example, a main driver routine ( in file MAIN.BAS ) calls subprogram MESSAGE ( in file MESSAGE.BAS) to display "HELLO". MAIN.BAS MESSAGE.BAS ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ~CALL MESSAGE( "HELLO") ³ ³ ~SUBPROGRAM MESSAGE( MSG$ ) ³ ³ END ³ ³ PRINT MSG$ ³ ³ ³ ³ ~RETURN ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄ.ÄÄÄÄÄÄÄÙ ³ ÛÛÛ MB preprocessor ³ v ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ 1 DIM A..#(00000),A..%(00000),A..!(00000),A..$(00000) ³ ³ 2 AAA$="HELLO":GOSUB 00007: ³ ³ 4 END ³ ³ 7 PRINT AAA$ ³ ³ 8 RETURN ³ ³ 9 STOP ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Example 3: This example illustrates the ~IF.. ~ELSEIF.. ~ELSE.. construct. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ~IF ( X = 1 ) THEN ³ ³ X = 2 ³ ³ ~ELSEIF ( Y = 1 ) THEN ³ ³ Y = 2 ³ ³ ~ELSE ³ ³ X = 0 ³ ³ Y = 0 ³ ³ ~ENDIF ³ ³ ³ ³ END ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄ.ÄÄÄÄÄÄÄÙ ³ ÛÛÛ MB preprocessor ³ v ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ 1 DIM A..#(00000),A..%(00000),A..!(00000),A..$(00000) ³ ³ 3 IF NOT((AAA!=1))GOTO 00007 ³ ³ 5 AAA!=2 ³ ³ 6 GOTO 00016 ³ ³ 7 IF NOT((BAA!=1))GOTO 00012 ³ ³ 9 BAA!=2 ³ ³ 10 GOTO 00016 ³ ³ 12 AAA!=0 ³ ³ 13 BAA!=0 ³ ³ 16 END ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ If a condition is not met, the entire section of code pertaining to that condition is skipped. ( Contrast this with the C language where a "break" statement must be used to avoid falling through a switch.) ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Example 4: Running the composite file (shown below) prints the values "0" and "1", not "1" and "2". Study the composite file to see why. MAIN.BAS BIG.BAS ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ DIM LIN(3) ³ ³ ~SUBPROGRAM BIG ( MEM ) ³ ³ ³ ³ DIM MEM(3) ³ ³ ~CALL BIG( LIN(1) ) ³ ³ ³ ³ PRINT LIN(1) ³ ³ MEM(1) = 1 ³ ³ PRINT LIN(2) ³ ³ MEM(2) = 2 ³ ³ ³ ³ ³ ³ END ³ ³ ~RETURN ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄ.ÄÄÄÄÄÄÄÙ ³ ÛÛÛ MB preprocessor ³ v ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ 1 DIM A..#(00000),A..%(00000),A..!(00003),A..$(00000) ³ ³ 5 BAA%=(1):GOSUB 00013: ³ ³ 6 PRINT A..!(1) ³ ³ 7 PRINT A..!(2) ³ ³ 9 END ³ ³ 13 A..!(BAA%+1)=1 ³ ³ 14 A..!(BAA%+2)=2 ³ ³ 15 RETURN ³ ³ 16 STOP ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ Example 5: This example illustrates Random I/O in MetaBASIC. The file "FILE" is opened and the METArecord SHOES is written to this file. ( The METArecord SHOES contains three members: BROWN, WHITE, and GREEN - for monochrome fans.) The same record is then read and the members BROWN and GREEN displayed. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ ~RECORD SHOES (BROWN,GREEN) ³ ³ ³ ³ SHOES.BROWN = 1 ³ ³ SHOES.GREEN = 2 ³ ³ ³ ³ RECNUM = 6 ³ ³ ³ ³ OPEN "FILE" AS #1,SHOES ³ ³ ³ ³ WRITE #1, RECNUM, SHOES ³ ³ READ #1, RECNUM, SHOES ³ ³ ³ ³ PRINT SHOES.BROWN ³ ³ PRINT SHOES.GREEN ³ ³ ³ ³ CLOSE ³ ³ END ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³ ÛÛÛ MB preprocessor ³ v ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ 1 DIM A..#(00000),A..%(00000),A..!(00000),A..$(00000) ³ ³ 5 AAA!=1 ³ ³ 6 BAA!=2 ³ ³ 7 CAA!=6 ³ ³ 8 OPEN "FILE" AS 1 LEN=8 ³ ³ 9 FIELD 1,4 AS V1.1$,4 AS V1.2$ ³ ³ 10 LSET V1.1$=MKS$(AAA!) ³ ³ 11 LSET V1.2$=MKS$(BAA!) ³ ³ 12 PUT 1,CAA! ³ ³ 13 GET 1,CAA! ³ ³ 14 AAA!=CVS(V1.1$) ³ ³ 15 BAA!=CVS(V1.2$) ³ ³ 17 PRINT AAA! ³ ³ 18 PRINT BAA! ³ ³ 19 CLOSE ³ ³ 20 END ³ ³ 24 END ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ Look at all those CVS's and MKS$. Nice to forget them, isn't it? Also note the two ENDS statements in lines 20 and 24. No BASIC programmer would do that (I hope!). If we want luxury, we must be willing to accept certain penalties. ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Conclusion ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ In summary, MetaBASIC is an interesting and useful asset for those engaged in writing BASIC code. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ File Name: ÛÛ metabas.txt ÛÛ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  they know more than I do about fixing it. There's alw