274 Chapter 7  BASIC Language for the 3458A  
depends on the individual sizes of the subprograms. A typical subprogram 
containing 10 commands (including the SUB and SUBEND commands) 
might average about 600 bytes. Refer to chapter 3 for more information on 
memory usage.
Can I Nest Subprograms?
Yes! Nesting subprograms is the ability to have one subprogram call 
(execute) another subprogram. You can nest up to 10 subprograms.
Writing and Loading Subprograms
The subprogram example programs in this section illustrate relatively simple  
3458A operations which you can copy and use in more complex mainline 
programs of your own design. This section also shows how to create and edit 
subprograms.
Note PROGRAMMING HINT
You should execute the SCRATCH command and download the 
subprograms from your system controller at the beginning of your test 
system program. This helps memory management for the 3458A and 
ensures that the subprograms are downloaded and ready when they are 
needed.
Executing the SUB command instructs the 3458A to store all subsequent 
commands, until the SUBEND command, in the specified subprogram.
Subprogram names may contain up to 10 characters. The first character must 
be a letter (A–Z) but the remaining nine characters can be letters, numbers 
(0–9), the underscore character ("_"), or the question mark ("?"). Subprogram 
names must not be the same as 3458A commands or parameters, previously 
defined array or variable names, or stored state names.
The following program shows how to create a simple subprogram which 
configures the multimeter to make three dc voltage measurements.
10 OUTPUT 722; "SUB DMM_CONF"
20 OUTPUT 722; "DCV8,0.00125"
30 OUTPUT 722; "NRDGS 3"
40 OUTPUT 722; "TRIG SGL"
50 OUTPUT 722; "SUBEND"
60 END
The two statements SUB DMM_CONF and SUBEND along with the three 
commands on line 20, 30, and 40 form the subprogram named DMM_CONF.
When a subprogram is entered, the 3458A checks for syntax errors just like 
any other commands. If the syntax is not correct, an error is generated and 
the command is not stored in the subprogram. You must then edit your 
subprogram in the system controller and download it again. The 3458A stores 
the subprogram in non-volatile memory. You can then execute the 
subprogram from either the front-panel keyboard or the system controller.