Specifications
Chapter 8 187
Save and Recall Files
Example Programs for Saving/Recalling a File
8. Save and Recall Files
Example program using macro (E4991A VBA)
Example 8-2 shows an example program for saving/recalling a file using a Macro. This
program is saved under the filename save_rec.bas on the sample programs disk. Below is
an explanation of the program’s details.
Lines 80 - 400 User selects the menu item for saving/recalling the specified file and
changes the current folder.
Lines 460 - 730 Displays the current folder and makes changes in it in the procedure
(Chn_curr_holder). Asks to input the file name again if the folder
name is inappropriate.
Lines 750 - 1020 Saves the state file under any filename in the procedure (Save_state).
Asks to input the file name again if an error occurs while saving the
file.
Lines 1040 - 1320 Recalls the state file in the procedure (Recall_state). Asks to input the
filename again if an error occurs while recalling the file.
Lines 1340 - 1880 Saves the data file under any filename in the procedure (Save_data).
Before saving, selects the kind of internal data array to be saved in the
file and the file type (ASCII or binary). Asks to input the filename
again if an error occurs while saving the file.
Lines 1900 - 2170 Recalls the data file (in binary format) in the procedure (Recall_data).
Asks to input the file name again if an error occurs while recalling the
file.
Lines 2190 - 2550 Saves the CITIfile under any filename in the procedure (Save_citi).
Selects a model type for the CITIfile before saving. Asks to input the
filename again if an error occurs while saving the file.
Lines 2570 - 2950 Saves the graphics file under any filename in the procedure
(Save_graphics). Selects saving the measurement display in either
bitmap format or JPEG format. Asks to input the file name again if an
error occurs while saving the file.
Example 8-2 Saving/Recalling (macro)
10 Sub Main()
20 Dim msg1 As String, msg2 As String, msg3 As String
30 Dim msg4 As String, msg5 As String, msg6 As String
40 Dim msg7 As String, msg8 As String, msg9 As String
50 Dim msg10 As String
60 Dim ans As String
70
80 menu:
90 msg1 = " Save/Recall Menu" & vbCrLf
100 msg2 = "------------------------------" & vbCrLf
110 msg3 = "1: returns/changes current holder" & vbCrLf
120 msg4 = "2: saves state file" & vbCrLf
130 msg5 = "3: recalls state file" & vbCrLf
140 msg6 = "4: saves data file" & vbCrLf
150 msg7 = "5: recall data file" & vbCrLf
160 msg8 = "6: saves CITIfile" & vbCrLf
170 msg9 = "7: saves graphics data file" & vbCrLf
180 msg10 = "8: quit" & vbCrLf
190 ans = InputBox(msg1 & msg2 & msg3 & msg4 & msg5 & msg6 &