-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcond3.bas
More file actions
181 lines (135 loc) · 5.59 KB
/
cond3.bas
File metadata and controls
181 lines (135 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Attribute VB_Name = "CodeCOND"
' (c) Copyright 1995-2026 by John J. Donovan
Option Explicit
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
' in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
' copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
' FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
' IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Type TypeColumn2 ' Demo and Jeol
ColumnConditionString As String
takeoff As String
kilovolts As String
beamcurrent As String
beamsize As String
End Type
Sub CondLoad()
' Loads the analytical condition defaults for user to change
ierror = False
On Error GoTo CondLoadError
' Load default
FormCOND.TextKiloVolts.Text = Format$(DefaultKiloVolts!)
FormCOND.TextTakeOff.Text = Format$(DefaultTakeOff!)
FormCOND.TextBeamCurrent.Text = Format$(DefaultBeamCurrent!)
FormCOND.TextBeamSize.Text = Format$(DefaultBeamSize!)
' Disable based on hardware options
If UCase$(app.EXEName) <> UCase$("Calczaf") Then
FormCOND.TextTakeOff.Enabled = False ' always disabled, except in CalcZAF
End If
Exit Sub
' Errors
CondLoadError:
MsgBox Error$, vbOKOnly + vbCritical, "CondLoad"
ierror = True
Exit Sub
End Sub
Sub CondSave()
' Save changed conditions to defaults
ierror = False
On Error GoTo CondSaveError
' Force reload of afactor arrays
AllAFactorUpdateNeeded = True
If Val(FormCOND.TextKiloVolts.Text) < MINKILOVOLTS! Or Val(FormCOND.TextKiloVolts.Text) > MAXKILOVOLTS! Then
msg$ = FormCOND.TextKiloVolts.Text & " kilovolts is out of range! (must be between " & Format$(MINKILOVOLTS!) & " and " & Format$(MAXKILOVOLTS!) & ")"
MsgBox msg$, vbOKOnly + vbExclamation, "CondSave"
ierror = True
Exit Sub
End If
If Val(FormCOND.TextTakeOff.Text) < 1# Or Val(FormCOND.TextTakeOff.Text) > 90# Then
msg$ = FormCOND.TextTakeOff.Text & " takeOff is out of range! (must be between 1 and 90)"
MsgBox msg$, vbOKOnly + vbExclamation, "CondSave"
ierror = True
Exit Sub
End If
If Val(FormCOND.TextBeamCurrent.Text) < 0.01 Or Val(FormCOND.TextBeamCurrent.Text) > 1000# Then
msg$ = "Beam current is out of range! (must be between 0.01 and 1000)"
MsgBox msg$, vbOKOnly + vbExclamation, "CondSave"
ierror = True
Exit Sub
End If
If Val(FormCOND.TextBeamSize.Text) < 0 Or Val(FormCOND.TextBeamSize.Text) > 500# Then
msg$ = "Beam size is out of range! (must be between 0 and 500)"
MsgBox msg$, vbOKOnly + vbExclamation, "CondSave"
ierror = True
Exit Sub
End If
' Save new defaults
DefaultKiloVolts! = Val(FormCOND.TextKiloVolts.Text)
DefaultTakeOff! = Val(FormCOND.TextTakeOff.Text)
DefaultBeamCurrent! = Val(FormCOND.TextBeamCurrent.Text)
DefaultBeamSize! = Val(FormCOND.TextBeamSize.Text)
Exit Sub
' Errors
CondSaveError:
MsgBox Error$, vbOKOnly + vbCritical, "CondSave"
ierror = True
Exit Sub
End Sub
Sub CondBrowseColumnCondition(tForm As Form)
' Browse for a column condition and update analytical conditions text fields if possible
ierror = False
On Error GoTo CondBrowseColumnConditionError
Dim tfilename As String
' Get new filename from user (SX100 or JEOL)
Call IOGetFileName(Int(2), "PCC", tfilename$, tForm)
If ierror Then Exit Sub
' Update column condition field
tForm.TextColumnConditionString.Text = tfilename$
' Extract voltage, current, mag and spot modes
' Update analytical condition fields (see also CondLoadColumn2)
' Update form for using column conditions
tForm.OptionColumnConditionMethod(1).Value = True
Exit Sub
' Errors
CondBrowseColumnConditionError:
MsgBox Error$, vbOKOnly + vbCritical, "CondBrowseColumnCondition"
ierror = True
Exit Sub
End Sub
Sub CondColumnLoad2(columnstring As String, tForm As Form)
' Loads the analytical condition defaults based on column condition string (Demo and Jeol)
ierror = False
On Error GoTo CondColumnLoad2Error
Dim tfilename As String
Dim colrec As TypeColumn2
' Check for string to load
If Trim$(columnstring) = vbNullString Then Exit Sub
tfilename$ = ApplicationCommonAppData$ & "COLUMN2.DAT"
If Dir$(tfilename$) = vbNullString Then Exit Sub
Open tfilename$ For Input As #Temp1FileNumber%
' Loop through file
Do Until EOF(Temp1FileNumber%)
Input #Temp1FileNumber%, colrec.takeoff$, colrec.kilovolts$, colrec.beamcurrent$, colrec.beamsize$, colrec.ColumnConditionString$
' Check for match
If MiscStringsAreSame(colrec.ColumnConditionString$, columnstring$) Then
' Load into text fields
tForm.TextTakeOff.Text = Trim$(colrec.takeoff$)
tForm.TextKiloVolts.Text = Trim$(colrec.kilovolts$)
tForm.TextBeamCurrent.Text = Trim$(colrec.beamcurrent$)
tForm.TextBeamSize.Text = Trim$(colrec.beamsize$)
Close (Temp1FileNumber%)
Exit Sub
End If
Loop
Close (Temp1FileNumber%)
Exit Sub
' Errors
CondColumnLoad2Error:
Close (Temp1FileNumber%)
MsgBox Error$, vbOKOnly + vbCritical, "CondColumnLoad2"
ierror = True
Exit Sub
End Sub