Using HP Instrument BASIC
Other Basic Features of IBASIC
Subprograms and COM Blocks
One of the most powerful constructs available is the subprogram. A
subprogram has its own \context" or state that is distinct from the
main program and all other subprograms. There are several benets of
subprograms.
The subprogram allows you to take advantage of the \top-down design"
method of programming.
You can remove all subtasks from the overall logic ow of the main
program.
You can debug the program by testing each subprogram independently
.
The subprograms can be used to reduce the overall size of the program.
Libraries of commonly used subprograms can be assembled for widespread
use.
Refer to the example program in the previous section. Line 180 calls a
subprogram to store data into a DOS le.
.
.
.
160 END IF
170 NEXT I
180 CALL Save_data
190 END
200 !
210 SUB Save_data
220 COM Data(*)
230 CREATE "data_file",1
240 ASSIGN @File TO "data_file";FORMAT ON
250 OUTPUT @File;Data(*)
260 ASSIGN @File TO *
270 SUBEND
1-22