Skip to content

PFP

Prepare for Program

This string function is used only by utility programs, which read and modify other programs as program files. It is meant to resolve references to named variables with a given symbol table in preparation for inclusion in a program file.

PFP (string-value, symbol-table)
string-value
is any string in the compiled form of a single Thoroughbred Basic statement.
symbol-table
is the actual symbol table portion of a Thoroughbred Basic program.

This function is generally available starting with release level 8.0.

Although Thoroughbred Basic is an interpretive language, actual program statements are kept in memory and on storage media in a pseudo-compiled state. This allows Thoroughbred Basic to maintain programs in less space in memory and on storage media and to execute individual statements more quickly than if all statements were maintained in their fully expanded, ‘LISTed’ form.

This function is not normally used within business applications, but is commonly found within system utilities, which manipulate program files. As such, it should not be used indiscriminately.

The PFP function is necessary only when processing Thoroughbred Basic program statements that have not been LOADed into memory. Programs that are LOADed into memory need only the CPL function to convert them from interpretive format into object-code form for storage.

In storage media format, each program line that refers to a named variable contains an index number into the symbol table for that name. The symbol table is maintained at the end of the program lines. Its position is obtained by the first few bytes in the actual program file that contains the program. Starting with the first byte in the program file as byte 1, the start of the symbol table is at the DEC (decimal) function of byte 5 for 4 bytes plus the constant 12. If the program file was contained in the string variable PROGRAM_FILE$, then the symbol table for that program file starts at DEC(PROGRAM_FILE$(5,4))+12.

Since this function is normally used to add program lines to an already existing program file, there should be a symbol table already in the program file. Should this function be used to build a program file from scratch, without an existing symbol table, the programmer should use $00$ as the starting symbol-table value.

LET OBJECT_CODE$ = PFP(CPL("100 VAR_1$=STR(NUM_1)"),SYMBOL_TABLE$)

places, in OBJECT_CODE$, the pseudo-compiled form of 100 VAR_1$=STR(NUM_1), after resolving the two variable names in this program line with the symbol table contained in the string SYMBOL_TABLE$.

LET OBJECT_CODE$ = CPL("100 VAR_1$=STR(NUM_1)")

places, in OBJECT_CODE$, the pseudo-compiled form of 100 VAR_1$=STR(NUM_1) using the symbol table of the program currently LOADed in memory.

CPL, LST, PFL, and PGM functions

From the Thoroughbred Basic Language Reference, Volume II: F–Q, version 8.9.1. Open this page in the PDF