HTBasic Help
×
Menu
Index

DELSUB

Deletes SUB or CSUB subprograms from memory.
 
 DELSUB context [,context...] [TO END]
 
Usage:
DELSUB FNProc$
DELSUB Transform TO END
DELSUB Unit1,Unit2,Unit3,Unit4
 
Example: DELSUB.BAS
 
Description:
DELSUB can delete one or more subprograms, CSUBs, or user-defined function subprograms from memory. If TO END is specified in the DELSUB statement, then the specified subprogram plus all following subprograms are deleted to the end of the program. If you specify a name and two subprograms both have that name, the first one is deleted. You cannot delete a subprogram if it is currently active or if it is referenced by a currently active ON event statement.
 
If a string expression specifies the subprogram name in the DELSUB 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 must be specified with the initial character in uppercase, and subsequent characters in lowercase. Subprogram pointers can also be used in CALL, INMEM, LOADSUB, and XREF statements.
 
See Also: