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