HTBasic Help
×
Menu
Index

LOADSUB

Loads a BASIC subprogram into memory.
 
 LOADSUB [context] FROM file-specifier
 
Usage:
LOADSUB Peek FROM "PEEK.COM"
LOADSUB FROM "Testfile"
LOADSUB FNSearch$ FROM "Sarfile"
LOADSUB ALL FROM Myfile$
LOADSUB Subptr$ FROM "ROUTINES.LIB"
 
Example:           LOADSUB.BAS
 
Description:
The LOADSUB statement loads subprograms at the end of the current program. It re-numbers the incoming subprogram lines. After loading a subprogram it also preruns the subprogram to check for COM block mismatches.
 
If ALL is specified, all subprograms in the file are loaded into memory. If a subprogram name is specified (either explicitly or in a string expression), only that subprogram is loaded into memory. These forms of LOADSUB are programmable.
 
LOADSUB FROM (no context specified) looks through a program and loads all subprogram references not yet in memory. The newly loaded subprograms are also looked through and any additional subprogram references not yet in memory are located and loaded into memory. After LOADSUB FROM has executed, if any subprogram references were not loaded into memory, an error is generated along with a listing of the subprogram names. LOADSUB FROM is not programmable.
 

Subprogram Pointer

If a string expression specifies the subprogram name in the LOADSUB statement, the string expression is called a subprogram pointer because it "points" to the subprogram rather than explicitly naming it. As the expression changes, the pointer points to different subprograms. The following example illustrates how this can be useful.
 
10   SUB Xform(X(*))
20     Method$="Xform"&VAL$(RANK(X))
30     IF NOT INMEM(Method$) THEN LOADSUB Method$
40     CALL Method$ WITH(X(*))
50     DELSUB Method$
60   SUBEND
 
The subprogram pointer must be specified with the initial character in uppercase and subsequent characters in lowercase. Subprogram pointers can also be used in CALL, DELSUB, INMEM, and XREF statements.
 
Back-porting
to HP BASIC:
The use of subprogram pointers in LOADSUB is a new HTBasic feature that is not available in HP BASIC. It should not be used in programs that must be ported back to HP BASIC.
 
See Also: