CPL
Compile Thoroughbred Basic Statement to Compiled Format
This string function converts a Thoroughbred Basic statement from interpretive format into compiled format.
Syntax
Section titled “Syntax”CPL (string-value [,ERR=line-ref|,ERC=error-code])string-value- is a Thoroughbred Basic program line in interpretive format.
line-ref- is the program line number or label to branch to if an error is produced by this function. However, no known condition causes a branch to line-ref.
error-code- is a programmer-defined error code. Valid values are positive or negative whole numbers.
Remarks
Section titled “Remarks”Thoroughbred Basic is an interpretive Business BASIC that maintains its source code in a compressed, pseudo-compiled format. Compiling conserves space and increases speed of execution.
When Thoroughbred Basic program lines are entered from the keyboard, the syntax is checked when the programmer presses the Enter key. When program lines exist in an ASCII file, this function provides the ability to test each program line for syntax errors.
If the Thoroughbred Basic statement string being compiled contains a syntax error, a flag is set (the third byte of the output string is set equal to $F3$), and when an attempt is made to execute or list the output of this function, an execution error is returned. The fourth byte contains the CHR of the error that occurred. The fifth and sixth bytes of the output string contain the position in which the error was found.
The Thoroughbred Basic program line being compiled does not need a program line number or label.
The compiled form of a Thoroughbred Basic statement may contain unprintable ASCII characters, which can be converted to printable form with the HTA function
LST is the inverse of this function.
Examples
Section titled “Examples”CPL (Q$)If Q$ = “0100 LET X=3”, returns a string which represents the compiled instruction to set the numeric variable X to the integer 3 at program line number 100.
CPL ("100X=3")returns the same string as the first example since both program lines are equivalent in Thoroughbred Basic.
00100 Q$="0100 LET X$ = 3"00110 C$=CPL(Q$)00120 IF C$(3,1)=$F3$ E=ASC(C$(4,1)), P=DEC(C$(5,2))-3, L$=LST(C$); PRINT "ERR =",E," AFTER POSITION",P; PRINT 'SB',L$(1,P),'SF',L$(P+1)illustrates a way of testing program code for syntax errors. In the example above, Q$ contains an invalid Thoroughbred Basic statement. The following messages will be displayed:
ERR = 20 AFTER POSITION 1500100 LET X$ = 3The second message line displays 3 as the invalid part of the statement. The numeral should be enclosed by quotation marks (“3”) for assignment to a string variable.
See also
Section titled “See also”From the Thoroughbred Basic Language Reference, Volume I: A–E, version 8.9.1. Open this page in the PDF