Specifications

170 Chapter 14
Using Printer
Sample Program
Sample Program
Example 14-1 shows a sample program that demonstrates how to print out data. You can
find the source file of this program, named printer.bas, on the sample program disk.
This sample program lets the user select a printer and outputs the specified type of data to
the printer.
The program is described in detail below:
Line 40 Sets the GPIB address.
Lines 60 to 80 Retrieves and displays the currently selected printer.
Lines 90 to 100 Prompts the user to confirm whether to use another printer and waits
until the user presses the y or n key.
Lines 110 to 140 If the user presses the y key in response to line 100, the program
passes control to a subprogram named Printer_select to change the
printer setting.
Lines 160 to 170 Retrieves the list (1)/single-point (0) measurement setting and stores
the setting into the List_stat variables.
Line 190 Allows the user to return to the entry start line and re-enter the data if
an error (such as an invalid entry) occurs while entering the number
that identifies the type of data to print out.
Lines 210 to 330 Displays the list of items that can be printed and prompts the user to
choose one of the items by typing in the appropriate number.
Line 340 Converts the entered value into an integer and stores it into the Content
variable.
Line 350 If Content is not within the range between 1 and 3 (for list
measurement) or the range between 1 and 2 (for single-point
measurement), the program returns the user to the entry start line.
Lines 370 to 450 Determines what to print out based on Content. If Content is 1 (i.e., the
user chooses to print the image on the LCD screen), the program sets
the color scheme to monochrome.
Line 470 Begins sending the data to the printer.
The Printer_select subprogram in lines 540 to 1030, which allows the user to select another
printer, is described below.
Lines 580 to 590 Retrieves the information on supported printers and stores the
information into the Info$ variable.
Lines 610 to 690 Extracts the printer information from the Info$ variable and stores the
information into the Prin_info$(*) array. Note that the printer
information includes the number of supported printers and the
specifics to the respective printers and is delimited with <newline>
characters (ASCII code 10).
Line 710 Stores the number of supported printers into the Printers variable.
Lines 720 to 840 Extracts the printer number and name from the information specific to
each supported printer and stores the printer number into the