CBASIC in General CBASIC2 Compile-Time Toggled Options XREF Cross Reference Facility Compiler Error Messages Run-Time Error Messages -- Warnings Run-Time Error Messages -- Error Codes CBASIC2 Reserved Words CBASIC2 Expression Hierarchy CBASIC2 Predefined Functions :CBASIC2: CBASIC in General CBASIà i compile BASI whic ma b execute o an flopp dis base CP/ syste havin a leas 20 byte o memory I orde t mak th bes us o th powe an flexibilit o CBASIC dua flopp dis syste an a leas 32 o memor i recommended I CBASI i execute in a system smaller than 20K, a CP/M LOAD ERROR may occur. Th CBASI syste consist o tw program -- CBASI an CRUN CBASI i th compiler an CRU i th run-tim intepreter I typica CBASI session th use wil writ th progra usin ED compil i usin CBASI (with the $B option to suppress listing), and run it using CRUN. Refer to the 84-page CBASIC manual -- C B A S I C A Commercially Oriented Compiler/Interpreter BASIC Language Facility for CP/M Systems February 17, 1978 CBASIC i a upward-compatabl (i term o sourc code extensio o th origina CBASIC I additio t al o th feature o th origina CBASIC, CBASIC2 adds the following: 1. Integer variables 2. Chaining with common variables 3. Additional pre-defined functions 4. Cross Reference capability Not tha CBASIC i upward-compatabl wit CBASI onl i term o th sourc cod files A IN fil create unde CBASI wil no execut with the Version 2 Run-Time Monitor (CRUN2). For further information, refer to the 100-page reference manual -- C B A S I C A Commercially Oriented Compiler/Interpreter BASIC Language Facility for CP/M Systems Version 2 May 1, 1979 :CBASIC2: CBASIC2 Compile-Time Toggled Options Compile toggle ar serie o switche tha ca b se whe th compile i executed Th toggle ar se b typin dollar-sig ($ followe b th lette designation o th desire toggle startin on spac o mor afte th progra nam o th comman line Toggle ma onl be set for the compiler. Examples of compiler toggles and invocation forms are -- CBAS2 INVENTRY $BGF B:CBAS2 A:COMPARE $GEC CBAS2 PAYROLL $B CBAS2 B:VALIDATE $E CBASIC Compiler Toggles TOGGL B Suppresse th listin o th progra o th consol durin compilation I a erro i detected th sourc lin wit th erro an th erro messag wil b printe eve i Toggl i set Toggl doe not affect listing to the printer (Toggle F) or disk file (Toggle G). Toggle B is initially off. TOGGLŠ C Suppresse th generatio o a IN file Engagin thi toggl wil provid synta chec withou th overhea o writin th intermediat file. Toggle C is initially off. TOGGL D Suppresse translatio o lower-cas letter t upper-case Fo example i Toggl i on 'AMT wil no refe t th sam variabl as 'amt'. Toggle D is initially off. TOGGLŠ E Cause th run-tim progra (CRUN2 t accompan an erro message wit th CBASI lin numbe i whic th erro occurred Toggl mus b se i orde fo th TRAC optio (se sectio 13. o th manual t work. Toggle E is initially off. TOGGLŠ F Cause th compile outpu listin t b printe o th LST: device in addition to the system console. Toggle F is initially off. TOGGLŠ G Cause th compile outpu listin t b writte t diskette Th fil containin th compile listin ha th sam nam a the .BAS file, but its type is .LST. Normall th dis listin wil b place o th sam sourc driv a th sourc file Th operato ma selec anothe driv b specifyin th desired drive, enclosed in parens, following the G toggle; for example, CBAS2 B:TAX $G(A:) extracts the source from drive B: and sends the listing to drive A:. Toggle G is initially off. :CBASIC2: XREF Cross Reference Facility Th XREF.CO͠ Cros Referenc utilit progra produce fil whic contain a alphabetize lis o al identifier use i CBASIà program Th usag o th identifie (function parameter o global i provided a wel a lis o eac lin i whic tha identifie i used Th fil create ha th sam nam a th CBASI sourc fil an i o typ XRF The standard output is 132 columns wide. The following command is used to invoke XREF -- XREF [disk ref] [$] ['title'] I th dis referenc i specified i instruct XRE a t wha dis to place the output on. The toggles are described on the next display. Th optiona titl fiel mus b th las fiel i th comman line Al character followin th firs apostroph o th comman lin u t th secon apostroph o unti th en o th comman lin becom th title Th titl i truncate t 3 character i th listin i 13 column wid and 20 characters if the D toggle (80 column listing) is specified. XREF Toggles Toggl A Cause th listin t b otpu t th lis devic a wel as the disk file. Toggl B Suppresse outpu t th disk I onl th toggl i specified, no output is produced. Toggl C Suppresse outpu t th dis an permit outpu t th list device; same as A and B combined. Toggle D: Causes output to be 80 columns wide instead of 132. Toggle E: Produces output with only the identifiers and their usage. Fo example th followin comman produce cros referenc listin on the list device which is 80 columns wide -- XREF PROG $CD :CBASIC: Compiler Error Messages Text Messages NO SOURCE FILE: .BAS Th compile coul no locat sourc fil use i eithe CBASI command or an INCLUDE directive. PROGRAM CONTAINS n UNMATCHED FOR STATEMENT(S) There are n FOR statements for which a NEXT could not be found. PROGRAM CONTAINS n UNMATCHED WHILE STATEMENT(S) There are n WHILE statements for which a WEND could not be found. WARNING: INVALID CHARACTER IGNORED Th previou lin contain a invali ASCI character thi characte is ignored by the compiler, and a question mark is printed in its place. OUT OF DISK SPACE Th compile ha ru ou o dis spac whil attemptin t writ either the INT or LST files. Text Messages (Con't) OUT OF DIRECTORY SPACE Th compile ha ru ou o director entrie whil attemptin t create or extend a file. DISK ERROR A disk error occurred while trying to read or write to a disk file. INCLUDE NESTING TOO DEEP NEAR LINE n A includ statemen nea lin i th sourc progra exceed th maximum level of nesting of source files. 2-Letter Error Codes BF -- Branch into Function A branch into a multiple line function from outside was attempted. BN -- Bad Number An invalid numeric constant was encountered. CE -- Close Error The intermediate (.INT) file could not be closed. CI -- Close Include An invalid file name in an %INCLUDE statement. CS -- COMMON Statement error COMMO statemen whic wa no th firs statemen i th progra wa detected. CV -- COMMON Variable error An improper reference to a subscripte variable in a COMMON statement. DE -- Disk Error A disk error occurred while trying to read the .BAS file. DF -- Disk Full Ther wa n spac o th dis o th dis director wa full Th .INT file was not created. DL -- Duplicate Line number Th sam lin numbe wa use o tw differen lines Othe compile error ma caus D erro messag t b printe eve i duplicat lin numbers do not exist. DP -- Defined Previously A variable in a DIM statement was previously defined. EF -- Exponential Format numbe i exponentia forma wa inpu wit n digit followin th E. FA -- Function Attribute functio nam appear o th lef sid o a assignmen statemen but is not within that function. FD -- Function Definition functio nam tha ha bee previousl define i bein redefine i a DEF statement. FE -- FOR Error mixe mod expressio exist i FO statemen whic th compile cannot correct. FI -- FOR Index A expressio whic i no a unsubscripte numeri variabl i bein used as a FOR loop index. FN -- Function parameter Number A function reference contains an incorrect number of parameters. FP -- Function Parameter type functio referenc paramete typ doe no matc th paramete typ used in the function's DEF statement. FU -- Function Undefined A function has been referenced before it has been defined. IE -- IF Expression A expressio use immediatel followin a IƠ evaluate t typ string. Only type numeric is permitted. IF -- In File variabl use i FIL statemen i o typ numeri wher typ string is required. IP -- Input Prompt An input prompt string is not surrounded by quotes. IS -- Invalid Subscript A subscripted variable was referenced before it was dimensioned. IT -- Invalid Toggle An invalid compiler directive was encountered. IU -- Invalid Use A variable defined as an array is used with no subscripts. MF -- Mixed Format An expression evaluates to type string when type numeric is required. MM -- Mixed Mode Variable o typ strin an typ numeri ar combine i th sam expression. MS -- Mixed String A numeric expression was used where a string expression is required. ND -- No DEFFN A FEND statement was encountered without a corresponding DEF. NI -- NEXT Index variabl reference b NEX statemen doe no matc th variabl referenced by the associated FOR statement. NU -- NEXT Unexpected A NEXT statement occurs without an associated FOR statement. OF -- Out of Function branc ou o multipl lin functio fro insid th functio wa attempted. OO -- ON Overflow More than 25 ON statements were used in the program. PM -- ?? DE statemen appeare withi multipl lin function Function may not be nested. SE -- Syntax Error The source line contains a syntax error. SF -- SAVEMEM File SAVEME statemen use a expressio o typ numeri t specif th fil t b loaded Thi expressio mus b string Possibl th quotation marks were left off a string constant. SN -- Subscript Number A subscripted variable contains an incorrect number of subscripts. SO -- Syntax Overflow Th expressio i to comple an shoul b simplifie an place o more than one line. TO -- Table Overflow Th progra i to larg fo th system Th progra mus b simplified or the system size increased. UL -- Undefined Line number A line number that does not exist has been referenced. US -- Undefined String A string has been terminated by a carriage return rather than quotes. VO -- Variable Overflow Variable names are too long for one statement. This should not occur. WE -- WHILE Error The expression immediately following a WHILE statement is not numeric. WU -- WHILE Undefined A WEND statement occurs without an associated WHILE statement. :CBASIC: Run-Time Error Messages -- Warnings Tw textua run-tim erro message ar presente b CRUN: NO INTERMEDIATE FILE fil nam wa no specifie wit th CRU command o n fil o typ .IN an th specifie fil nam wa foun o disk. IMPROPER INPUT - REENTER Thi messag occur whe th field entere fro th consol d no matc th fiel specifie i th INPU statement Thi ca occu whe fiel type d no matc o th numbe o field entere i differen fro th numbe o field specified Al field specifie b th INPU statemen mus b reentered. 2-Letter Warning Codes DZ -- Divide by Zero numbe wa divide b zero Th resul i se t th larges vali CBASI number. FL -- Field Length fiel lengt greate tha 25 byte wa encountere durin REA LINE Onl th firs 25 character o th recor ar retained. LN -- Logarithm error Th argumen give i th LO functio wa zer o negative Th valu o th argumen i returned. NE -- NEgative number negativ numbe wa specifie followin th rais t powe operato (^) Th absolut valu i use i th calculation. OF -- OverFlow calculatio produce numbe to large Th resul i se o th larges vali CBASI number. SQ -- SQuare root error negativ numbe wa specifie i th SQ function Th absolut valu i used. :CBASIC: Run-Time Error Messages -- Error Codes AC -- AsCii error Th strin use a th argumen i a AS functio evaluate t nul string. BN -- BUFF Number Th valu followin th BUF optio i a OPE o CREAT statemen i less than 1 or greater than 52. CC -- Chain Code chaine program' cod are i large tha th mai program' cod area. CD -- Chain Data chaine program' dat are i large tha th mai program' dat area. CE -- Close Error An error occurred upon closing a file. CF -- Chain Function chaine program' constan are i large tha th mai program' constant area. CP -- Chain Var Storage chaine program' variabl storag are i large tha th mai program's variable storage area. CS -- Chain SAVEMEM chaine progr reserve differenc amoun o memor wit SAVEME statement than the main program. CU -- Close Undefined file clos statemen specifie fil numbe tha wa no active. DF -- Defined File A OPE o CREAT wa specifie wit fil numbe tha wa alread active. DU -- Delete Undefined file DELET statemen specifie fil numbe tha wa no active. DW -- Disk Write error A erro occurre whil writin t file Thi occur whe eithe th director o th dis i full. EF -- End of File rea pas th en o fil occurre o fil fo whic n IƠ EN statemen ha bee executed. ER -- Error in Record A attemp wa mad t writ recor o lengt greate tha th maximu recor siz specifie i th associate OPEN CREATE o FIL statement. FR -- File Rename A attemp wa mad t renam fil t a existin fil name. FT -- File Toggle A FILE statement was executed when 20 files were already active. FU -- File Undefined A attemp wa mad t rea o writ t fil tha wa no active. IF -- Invalid File name A file name was invalid. IR -- Invalid Record number A record number less than one was specified. IV -- Invalid Version A attemp wa mad t execut a IN fil create b Versio Compiler. IX -- ?? FENĠ statemen wa encountere prio t executin RETUR statement. LW -- Line Width lin widt les tha o greate tha 13 wa specifie i a LPRINTE WIDT statement. ME -- MAKE Error A erro occurre whil creatin o extendin fil becaus th dis director wa full. MP -- MATCH Parameter Th thir paramete i MATC functio wa zer o negative. NF -- Number of FILE Th fil numbe specifie wa les tha o greate tha 20. NM -- No Memory There was insufficient memory to load the program. NN -- No Number field A attemp wa mad t prin numbe wit PRIN USIN statemen bu ther wa no numeri dat fiel i th USIN string. NS -- No String field A attemp wa mad t prin strin wit PRIN USIN statemen bu ther wa no strin fiel i th USIN string. OD -- Overflow Data REAĠ statemen wa execute wit n DAT available. OE -- OPEN Error A attemp wa mad t OPE fil tha didn' exis an fo whic n I EN statemen ha bee previousl executed. OI -- ON Index Th expressio specifie i a O .. GOSU o a OΠ .. GOT statemen evaluate t numbe les tha o greate tha th numbe o lin number containe i th statement. OM -- Overflow Memory The program ran out of memory during execution. QE -- Quote Error A attemp wa mad t PRIN t fil strin containin quotatio mark. RB -- Random BUFF Rando acces wa attempte t fil activate wit th BUFƠ optio specifying more than 1 buffer. RE -- READ Error A attemp wa mad t rea pas th en o recor i fixe file. RG -- RETURN with no GOSUB A RETURN occurred for which there was no GOSUB. RU -- Random Undefined rando rea o prin wa attempte t othe tha fixe file. SB -- SuBscript A arra subscrip wa use whic exceede th boundarie fo whic th arra wa defined. SL -- String Length concatenatio operatio resulte i strin o mor tha 25 bytes. SO -- SAVEMEM Th fil specifie i SAVEME statemen coul no b locate o th referenced disk. SS -- SubString error Th secon paramete o MID functio wa zer o negative. TF -- Too many Files A attemp wa mad t hav mor tha 2 activ file simultaneously. TL -- TAB Length TA statemen containe paramete les tha o greate tha th curren lin width. UN -- UNdefined edit string PRIN USIN statemen wa execute wit nul edi string. WR -- WRite error A attemp wa mad t writ t fil afte i ha bee read bu befor i ha bee rea t th en o th file. :CBASIC: CBASIC Reserved Words ABS AND AS ASC ATN BUFF CALL CHAIN CHR$ CLOSE COMMAND$ COMMON CONCHAR% CONSOLE CONSTAT% COS CREATE DATA DEF DELETE DIM ELSE END EQ EXP FEND FILE FOR FRE GE GO GOSUB GOTO GT IF INITIALIZE INP INPUT INT INT% LE LEFT$ LEN LET LINE LOG LPRINTER LT MATCH MID$ NE NEXT NOT ON OPEN OR OUT PEEK POKE POS PRINT RANDOMIZE READ RECL RECS REM REMARK RENAME RESTORE RETURN RIGHT$ RND SADD SGN SIN SIZE SQR STEP STOP STR$ SUB TAB TAN THEN TO UCASE$ USING VAL WEND WHILE WIDTH XOR :CBASIC2: Expression Hierarchy The Hierarchy for expression evaluation is a follows -- 1. nested parentheses () 2. power operator ^ 3. * / 4. + - concatenation[+] unary[+ -] 5. relational operators: < <= > >= = <> LT LE GT GE EQ NE 6. NOT 7. AND 8. OR XOR :CBASIC2: Predefined Functions I/O Functions CONSTAT - Return th consol statu a a integer I ready logica TRUE is returned. CONCHAR% - Reads one character from the console device. Machine-Language Functions PEEK () - Return th content o th memor locatio give b th expression. POKE , - Low-orde eigh bit o secon expressio ar store i memor location selected by first expression. CALL - CALL a machine language program at address specified. SAVEMEM , - Reserv into the reserved area. Numeric Functions FRE ABS(x) INT(x) INT%(x) FLOAT(i%) RND SGN(x) ATN(x) COS(x) EXP(x) LOG(x) [e] SIN(x) SQR(x) TAN(x) String Functions ASC(a$) CHR$(i%) LEFT$(a$,i%) LEN(a$) UCASE$(a$) MATCH(a$,b$,i%) MID$(a$,i%,j%) RIGHT$(a$,i%) STR$(x) VAL(a$) COMMAND$ SADD(a$) Disk Functions RENAME(a$,b$) SIZE(a$) User-Defined Functions The general forms are -- [] DEF [] = and [] DEF [] . . . [] FEND