-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathanalyze4.bas
More file actions
563 lines (444 loc) · 24.6 KB
/
analyze4.bas
File metadata and controls
563 lines (444 loc) · 24.6 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
Attribute VB_Name = "CodeANALYZE4"
' (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.
Global TimerToggle As Integer
Sub AnalyzeUpdateList(mode As Integer, tForm As Form, tList As ListBox)
' Updates the sample list box for FormANALYZE and FormPLOT, FormLOCATE and FormIMAGEEDIT and FormACQUIRE
' mode = 0 select last item in list
' mode = 1 select previously selected items in list
ierror = False
On Error GoTo AnalyzeUpdateListError
Dim samplerow As Integer
Dim i As Integer
' Save current selections if indicated
If mode% = 1 And tList.ListCount > 0 Then
ReDim ListSelected(0 To tList.ListCount - 1) As Integer
For i% = 0 To tList.ListCount - 1
ListSelected%(i%) = tList.Selected(i%)
Next i%
End If
' Loop through samples and load appropriate samples
tList.Clear
For samplerow% = 1 To NumberofSamples%
' Load standards or unknowns or all
If tForm.OptionStandard.value = True And SampleTyps%(samplerow%) <> 1 Then GoTo 1000
If tForm.OptionUnknown.value = True And SampleTyps%(samplerow%) <> 2 Then GoTo 1000
If tForm.OptionWavescan.value = True And SampleTyps%(samplerow%) <> 3 Then GoTo 1000
' Check for FormANALYZE and if so, check display only samples with data checkbox
If tForm.Name = "FormANALYZE" Or tForm.Name = "FormPLOT_WAVE" Or tForm.Name = "FormPLOT" Then
If tForm.CheckOnlyDisplaySamplesWithData.value = vbChecked And SampleDels%(samplerow%) = True Then GoTo 1000
End If
' Load number set and name
msg$ = SampleGetString(samplerow%)
tList.AddItem msg$
tList.ItemData(tList.NewIndex) = samplerow%
1000: Next samplerow%
' Set list box to last loaded sample
If tList.ListCount > 0 Then
If mode% = 0 Then
tList.ListIndex = tList.ListCount - 1
tList.Selected(tList.ListCount - 1) = True
' Select previously selected items
Else
If tList.ListCount > 0 Then
ReDim Preserve ListSelected(0 To tList.ListCount - 1) As Integer
End If
For i% = 0 To tList.ListCount - 1
tList.Selected(i%) = ListSelected%(i%)
Next i%
End If
End If
Exit Sub
' Errors
AnalyzeUpdateListError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeUpdateList"
ierror = True
Exit Sub
End Sub
Sub AnalyzeCombineSamples(mode As Integer, tmpsample() As TypeSample, sample() As TypeSample)
' Combine the samples (add tmpsample to sample)
' mode = 1 load analyzed elements only
' mode = 3 load specified elements only
ierror = False
On Error GoTo AnalyzeCombineSamplesError
Dim i As Integer, j As Integer
Dim ielm As Integer, m As Integer
' Load each analyzed elements
If mode% = 1 Then
For i% = 1 To tmpsample(1).LastElm%
If tmpsample(1).DisableAcqFlag%(i%) = 0 Then
' Find if element is already loaded as an analyzed element, and if so warn
ielm% = IPOS5(Int(0), i%, tmpsample(), sample())
If ielm% > 0 And tmpsample(1).DisableQuantFlag%(i%) = 0 Then
If sample(1).DisableQuantFlag%(ielm%) = 0 Then ' if not disabled in first sample, warn user
Call IOWriteLog("Warning in AnalyzeCombineSamples: element " & tmpsample(1).Elsyms$(i%) & " is already present in the combined sample and will not be loaded again")
GoTo 4000
End If
End If
' Increment number of analyzed elements
If sample(1).LastElm% + 1 > MAXCHAN% Then GoTo AnalyzeCombineSamplesTooManyAnalyzedElements
sample(1).LastElm% = sample(1).LastElm% + 1
' Add conditions to array (the whole point being different voltages and/or currents!!!)
sample(1).TakeoffArray!(sample(1).LastElm%) = tmpsample(1).TakeoffArray!(i%)
sample(1).KilovoltsArray!(sample(1).LastElm%) = tmpsample(1).KilovoltsArray!(i%)
sample(1).BeamCurrentArray!(sample(1).LastElm%) = tmpsample(1).BeamCurrentArray!(i%)
sample(1).BeamSizeArray!(sample(1).LastElm%) = tmpsample(1).BeamSizeArray!(i%)
sample(1).ColumnConditionMethodArray%(sample(1).LastElm%) = tmpsample(1).ColumnConditionMethodArray%(i%)
sample(1).ColumnConditionStringArray$(sample(1).LastElm%) = tmpsample(1).ColumnConditionStringArray$(i%)
' Now add in normal element parameters
sample(1).Elsyms$(sample(1).LastElm%) = tmpsample(1).Elsyms$(i%)
sample(1).Xrsyms$(sample(1).LastElm%) = tmpsample(1).Xrsyms$(i%)
sample(1).numcat%(sample(1).LastElm%) = tmpsample(1).numcat%(i%)
sample(1).numoxd%(sample(1).LastElm%) = tmpsample(1).numoxd%(i%)
sample(1).ElmPercents!(sample(1).LastElm%) = tmpsample(1).ElmPercents!(i%)
sample(1).AtomicCharges!(sample(1).LastElm%) = tmpsample(1).AtomicCharges!(i%)
sample(1).AtomicWts!(sample(1).LastElm%) = tmpsample(1).AtomicWts!(i%)
' 0=linear, 1=average, 2=high only, 3=low only, 4=exponential, 5=slope hi, 6=slope lo, 7=polynomial, 8=multi-point
sample(1).OffPeakCorrectionTypes%(sample(1).LastElm%) = tmpsample(1).OffPeakCorrectionTypes%(i%)
sample(1).BackgroundExponentialBase!(sample(1).LastElm%) = tmpsample(1).BackgroundExponentialBase!(i%)
sample(1).BackgroundSlopeCoefficients!(1, sample(1).LastElm%) = tmpsample(1).BackgroundSlopeCoefficients!(1, i%)
sample(1).BackgroundSlopeCoefficients!(2, sample(1).LastElm%) = tmpsample(1).BackgroundSlopeCoefficients!(2, i%)
sample(1).BackgroundPolynomialPositions!(1, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialPositions!(1, i%)
sample(1).BackgroundPolynomialPositions!(2, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialPositions!(2, i%)
sample(1).BackgroundPolynomialPositions!(3, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialPositions!(3, i%)
sample(1).BackgroundPolynomialCoefficients!(1, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialCoefficients!(1, i%)
sample(1).BackgroundPolynomialCoefficients!(2, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialCoefficients!(2, i%)
sample(1).BackgroundPolynomialCoefficients!(3, sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialCoefficients!(3, i%)
sample(1).BackgroundPolynomialNominalBeam!(sample(1).LastElm%) = tmpsample(1).BackgroundPolynomialNominalBeam!(i%)
' Load other real time element parameters
sample(1).BraggOrders%(sample(1).LastElm%) = tmpsample(1).BraggOrders%(i%)
sample(1).MotorNumbers%(sample(1).LastElm%) = tmpsample(1).MotorNumbers%(i%)
sample(1).OrderNumbers%(sample(1).LastElm%) = tmpsample(1).OrderNumbers%(i%)
sample(1).CrystalNames$(sample(1).LastElm%) = tmpsample(1).CrystalNames$(i%)
sample(1).Crystal2ds!(sample(1).LastElm%) = tmpsample(1).Crystal2ds!(i%)
sample(1).CrystalKs!(sample(1).LastElm%) = tmpsample(1).CrystalKs!(i%)
sample(1).OnPeaks!(sample(1).LastElm%) = tmpsample(1).OnPeaks!(i%)
sample(1).HiPeaks!(sample(1).LastElm%) = tmpsample(1).HiPeaks!(i%)
sample(1).LoPeaks!(sample(1).LastElm%) = tmpsample(1).LoPeaks!(i%)
sample(1).StdAssigns%(sample(1).LastElm%) = tmpsample(1).StdAssigns%(i%)
sample(1).BackgroundTypes%(sample(1).LastElm%) = tmpsample(1).BackgroundTypes%(i%) ' 0=off-peak, 1=MAN, 2=multipoint
sample(1).DeadTimes!(sample(1).LastElm%) = tmpsample(1).DeadTimes!(i%)
sample(1).Baselines!(sample(1).LastElm%) = tmpsample(1).Baselines!(i%)
sample(1).Windows!(sample(1).LastElm%) = tmpsample(1).Windows!(i%)
sample(1).Gains!(sample(1).LastElm%) = tmpsample(1).Gains!(i%)
sample(1).Biases!(sample(1).LastElm%) = tmpsample(1).Biases!(i%)
sample(1).InteDiffModes%(sample(1).LastElm%) = tmpsample(1).InteDiffModes%(i%)
sample(1).DetectorSlitSizes$(sample(1).LastElm%) = tmpsample(1).DetectorSlitSizes$(i%)
sample(1).DetectorSlitPositions$(sample(1).LastElm%) = tmpsample(1).DetectorSlitPositions$(i%)
sample(1).DetectorModes$(sample(1).LastElm%) = tmpsample(1).DetectorModes$(i%)
sample(1).IntegratedIntensitiesUseIntegratedFlags%(sample(1).LastElm%) = tmpsample(1).IntegratedIntensitiesUseIntegratedFlags%(i%)
sample(1).IntegratedIntensitiesInitialStepSizes!(sample(1).LastElm%) = tmpsample(1).IntegratedIntensitiesInitialStepSizes!(i%)
sample(1).IntegratedIntensitiesMinimumStepSizes!(sample(1).LastElm%) = tmpsample(1).IntegratedIntensitiesMinimumStepSizes!(i%)
sample(1).IntegratedIntensitiesIntegratedTypes%(sample(1).LastElm%) = tmpsample(1).IntegratedIntensitiesIntegratedTypes%(i%)
' Interference correction (ok for combining)
For j% = 1 To MAXINTF%
sample(1).StdAssignsIntfElements$(j%, sample(1).LastElm%) = tmpsample(1).StdAssignsIntfElements$(j%, i%)
sample(1).StdAssignsIntfXrays$(j%, sample(1).LastElm%) = tmpsample(1).StdAssignsIntfXrays$(j%, i%)
sample(1).StdAssignsIntfStds%(j%, sample(1).LastElm%) = tmpsample(1).StdAssignsIntfStds%(j%, i%)
sample(1).StdAssignsIntfOrders%(j%, sample(1).LastElm%) = tmpsample(1).StdAssignsIntfOrders%(j%, i%)
Next j%
' Volatile element correction
sample(1).VolatileCorrectionUnks%(sample(1).LastElm%) = tmpsample(1).VolatileCorrectionUnks%(i%)
sample(1).SpecifiedAreaPeakFactors!(sample(1).LastElm%) = tmpsample(1).SpecifiedAreaPeakFactors!(i%)
' Blank correction
sample(1).BlankCorrectionUnks%(sample(1).LastElm%) = tmpsample(1).BlankCorrectionUnks%(i%)
sample(1).BlankCorrectionLevels!(sample(1).LastElm%) = tmpsample(1).BlankCorrectionLevels!(i%)
sample(1).VolatileFitCurvatures!(sample(1).LastElm%) = tmpsample(1).VolatileFitCurvatures!(i%)
sample(1).PeakingBeforeAcquisitionElementFlags%(sample(1).LastElm%) = tmpsample(1).PeakingBeforeAcquisitionElementFlags%(i%)
sample(1).VolatileFitTypes%(sample(1).LastElm%) = tmpsample(1).VolatileFitTypes%(i%)
' MAN correction
sample(1).MANAbsCorFlags%(sample(1).LastElm%) = tmpsample(1).MANAbsCorFlags%(i%)
sample(1).MANLinearFitOrders%(sample(1).LastElm%) = tmpsample(1).MANLinearFitOrders%(i%)
For j% = 1 To MAXMAN%
sample(1).MANStdAssigns%(j%, sample(1).LastElm%) = tmpsample(1).MANStdAssigns%(j%, i%)
Next j%
' Count data and time
For j% = 1 To MAXROW%
sample(1).OnPeakCounts!(j%, sample(1).LastElm%) = tmpsample(1).OnPeakCounts!(j%, i%)
sample(1).HiPeakCounts!(j%, sample(1).LastElm%) = tmpsample(1).HiPeakCounts!(j%, i%)
sample(1).LoPeakCounts!(j%, sample(1).LastElm%) = tmpsample(1).LoPeakCounts!(j%, i%)
sample(1).OnCountTimes!(j%, sample(1).LastElm%) = tmpsample(1).OnCountTimes!(j%, i%)
sample(1).HiCountTimes!(j%, sample(1).LastElm%) = tmpsample(1).HiCountTimes!(j%, i%)
sample(1).LoCountTimes!(j%, sample(1).LastElm%) = tmpsample(1).LoCountTimes!(j%, i%)
sample(1).UnknownCountFactors!(j%, sample(1).LastElm%) = tmpsample(1).UnknownCountFactors!(j%, i%)
sample(1).UnknownMaxCounts&(j%, sample(1).LastElm%) = tmpsample(1).UnknownMaxCounts&(j%, i%)
sample(1).VolCountTimesStart(j%, sample(1).LastElm%) = tmpsample(1).VolCountTimesStart(j%, i%)
sample(1).VolCountTimesStop(j%, sample(1).LastElm%) = tmpsample(1).VolCountTimesStop(j%, i%)
sample(1).VolCountTimesDelay(j%, sample(1).LastElm%) = tmpsample(1).VolCountTimesDelay(j%, i%)
' Set line status to deleted if additional sample line is deleted
If Not tmpsample(1).LineStatus%(j%) Then sample(1).LineStatus%(j%) = False
Next j%
' Load different beam currents for each line for each line/element (combined analysis only)
For j% = 1 To MAXROW%
If Not tmpsample(1).CombinedConditionsFlag Then
sample(1).OnBeamCountsArray!(j%, sample(1).LastElm%) = tmpsample(1).OnBeamCounts!(j%)
sample(1).AbBeamCountsArray!(j%, sample(1).LastElm%) = tmpsample(1).AbBeamCounts!(j%)
sample(1).OnBeamCountsArray2!(j%, sample(1).LastElm%) = tmpsample(1).OnBeamCounts2!(j%)
sample(1).AbBeamCountsArray2!(j%, sample(1).LastElm%) = tmpsample(1).AbBeamCounts2!(j%)
Else
sample(1).OnBeamCountsArray!(j%, sample(1).LastElm%) = tmpsample(1).OnBeamCountsArray!(j%, i%)
sample(1).AbBeamCountsArray!(j%, sample(1).LastElm%) = tmpsample(1).AbBeamCountsArray!(j%, i%)
sample(1).OnBeamCountsArray2!(j%, sample(1).LastElm%) = tmpsample(1).OnBeamCountsArray2!(j%, i%)
sample(1).AbBeamCountsArray2!(j%, sample(1).LastElm%) = tmpsample(1).AbBeamCountsArray2!(j%, i%)
End If
Next j%
' Save last count times
sample(1).LastOnCountTimes!(sample(1).LastElm%) = tmpsample(1).LastOnCountTimes!(i%)
sample(1).LastHiCountTimes!(sample(1).LastElm%) = tmpsample(1).LastHiCountTimes!(i%)
sample(1).LastLoCountTimes!(sample(1).LastElm%) = tmpsample(1).LastLoCountTimes!(i%)
sample(1).LastWaveCountTimes!(sample(1).LastElm%) = tmpsample(1).LastWaveCountTimes!(i%)
sample(1).LastPeakCountTimes!(sample(1).LastElm%) = tmpsample(1).LastPeakCountTimes!(i%)
sample(1).LastQuickCountTimes!(sample(1).LastElm%) = tmpsample(1).LastQuickCountTimes!(i%)
sample(1).LastCountFactors!(sample(1).LastElm%) = tmpsample(1).LastCountFactors!(i%)
sample(1).LastMaxCounts&(sample(1).LastElm%) = tmpsample(1).LastMaxCounts&(i%)
sample(1).StdAssignsFlag%(sample(1).LastElm%) = tmpsample(1).StdAssignsFlag%(i%)
sample(1).DisableQuantFlag%(sample(1).LastElm%) = tmpsample(1).DisableQuantFlag%(i%)
sample(1).DisableAcqFlag%(sample(1).LastElm%) = tmpsample(1).DisableAcqFlag%(i%)
sample(1).WDSWaveScanHiPeaks!(sample(1).LastElm%) = tmpsample(1).WDSWaveScanHiPeaks!(i%)
sample(1).WDSWaveScanLoPeaks!(sample(1).LastElm%) = tmpsample(1).WDSWaveScanLoPeaks!(i%)
sample(1).WDSWaveScanPoints%(sample(1).LastElm%) = tmpsample(1).WDSWaveScanPoints%(i%)
sample(1).WDSQuickScanHiPeaks!(sample(1).LastElm%) = tmpsample(1).WDSQuickScanHiPeaks!(i%)
sample(1).WDSQuickScanLoPeaks!(sample(1).LastElm%) = tmpsample(1).WDSQuickScanLoPeaks!(i%)
sample(1).WDSQuickScanSpeeds!(sample(1).LastElm%) = tmpsample(1).WDSQuickScanSpeeds!(i%)
sample(1).NthPointAcquisitionFlags%(sample(1).LastElm%) = tmpsample(1).NthPointAcquisitionFlags%(i%)
sample(1).NthPointAcquisitionIntervals%(sample(1).LastElm%) = tmpsample(1).NthPointAcquisitionIntervals%(i%)
' Do not load integrated intensities here (first sample loaded must have the only integrated intensities when combining samples!)
If tmpsample(1).IntegratedIntensitiesUseIntegratedFlags(i%) Then
End If
' Load MPB parameters
sample(1).MultiPointNumberofPointsAcquireHi%(sample(1).LastElm%) = tmpsample(1).MultiPointNumberofPointsAcquireHi%(i%)
sample(1).MultiPointNumberofPointsAcquireLo%(sample(1).LastElm%) = tmpsample(1).MultiPointNumberofPointsAcquireLo%(i%)
sample(1).MultiPointNumberofPointsIterateHi%(sample(1).LastElm%) = tmpsample(1).MultiPointNumberofPointsIterateHi%(i%)
sample(1).MultiPointNumberofPointsIterateLo%(sample(1).LastElm%) = tmpsample(1).MultiPointNumberofPointsIterateLo%(i%)
sample(1).MultiPointBackgroundFitType%(sample(1).LastElm%) = tmpsample(1).MultiPointBackgroundFitType%(i%) ' 0 = linear, 1 = 2nd order polynomial, 2 = exponential
' Update multi-point acquisition positions and count times only
For m% = 1 To MAXMULTI%
sample(1).MultiPointAcquirePositionsHi!(sample(1).LastElm%, m%) = tmpsample(1).MultiPointAcquirePositionsHi!(i%, m%)
sample(1).MultiPointAcquirePositionsLo!(sample(1).LastElm%, m%) = tmpsample(1).MultiPointAcquirePositionsLo!(i%, m%)
sample(1).MultiPointAcquireLastCountTimesHi(sample(1).LastElm%, m%) = tmpsample(1).MultiPointAcquireLastCountTimesHi(i%, m%)
sample(1).MultiPointAcquireLastCountTimesLo(sample(1).LastElm%, m%) = tmpsample(1).MultiPointAcquireLastCountTimesLo(i%, m%)
'sample(1).MultiPointProcessManualFlagHi%(sample(1).LastElm%, m%) = tmpsample(1).MultiPointProcessLastManualFlagHi%(i%, m%)
'sample(1).MultiPointProcessManualFlagLo%(sample(1).LastElm%, m%) = tmpsample(1).MultiPointProcessLastManualFlagLo%(i%, m%)
Next m%
sample(1).UnknownCountTimeForInterferenceStandardChanFlag(sample(1).LastElm%) = tmpsample(1).UnknownCountTimeForInterferenceStandardChanFlag(i%)
sample(1).SecondaryFluorescenceBoundaryFlag(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryFlag(i%)
sample(1).SecondaryFluorescenceBoundaryKratiosDATFile$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryKratiosDATFile$(i%)
sample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine1$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine1$(i%)
sample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine2$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine2$(i%)
sample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine3$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryKratiosDATFileLine3$(i%)
sample(1).SecondaryFluorescenceBoundaryMatA_String$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryMatA_String$(i%)
sample(1).SecondaryFluorescenceBoundaryMatB_String$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryMatB_String$(i%)
sample(1).SecondaryFluorescenceBoundaryMatBStd_String$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBoundaryMatBStd_String$(i%)
sample(1).ConditionNumbers%(sample(1).LastElm%) = tmpsample(1).ConditionNumbers%(i%) ' list order
sample(1).AtomicCharges!(sample(1).LastElm%) = tmpsample(1).AtomicCharges!(i%)
sample(1).AtomicWts!(sample(1).LastElm%) = tmpsample(1).AtomicWts!(i%)
sample(1).EffectiveTakeOffs!(sample(1).LastElm%) = tmpsample(1).EffectiveTakeOffs!(i%)
sample(1).SecondaryFluorescenceBraggFlag%(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBraggFlag%(i%)
sample(1).SecondaryFluorescenceBraggImageNumber%(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBraggImageNumber%(i%)
sample(1).SecondaryFluorescenceBraggImageFileName$(sample(1).LastElm%) = tmpsample(1).SecondaryFluorescenceBraggImageFileName$(i%)
End If
4000: Next i%
' Update number of analyzed elements
sample(1).LastChan% = sample(1).LastElm%
End If
' Load the specified elements last, set x-ray, etc. to blank
If mode% = 3 Then
For i% = tmpsample(1).LastElm% + 1 To tmpsample(1).LastChan%
' Find element, add if not already added
ielm% = IPOS5(Int(1), i%, tmpsample(), sample())
If ielm% > 0 Then GoTo 6000
' Increment number of specified elements
If sample(1).LastChan% + 1 > MAXCHAN% Then GoTo AnalyzeCombineSamplesTooManyElements
sample(1).LastChan% = sample(1).LastChan% + 1
' Load specified element parameters
sample(1).Elsyms$(sample(1).LastChan%) = tmpsample(1).Elsyms$(i%)
sample(1).Xrsyms$(sample(1).LastChan%) = vbNullString
' Make sure cations are loaded
sample(1).numcat%(sample(1).LastChan%) = tmpsample(1).numcat%(i%)
sample(1).numoxd%(sample(1).LastChan%) = tmpsample(1).numoxd%(i%)
sample(1).AtomicCharges!(sample(1).LastChan%) = tmpsample(1).AtomicCharges!(i%)
sample(1).AtomicWts!(sample(1).LastChan%) = tmpsample(1).AtomicWts!(i%)
sample(1).ElmPercents!(sample(1).LastChan%) = tmpsample(1).ElmPercents!(i%)
6000: Next i%
' Load coating parameters and EDS use flag???
'sample(1).CoatingDensity! = tmpsample(1).CoatingDensity!
'sample(1).CoatingElement% = tmpsample(1).CoatingElement%
'sample(1).CoatingFlag% = tmpsample(1).CoatingFlag%
'sample(1).CoatingThickness! = tmpsample(1).CoatingThickness!
'sample(1).EDSSpectraUseFlag = tmpsample(1).EDSSpectraUseFlag
' Since loading specified elements, load stoichiometry assinments
sample(1).FormulaElementFlag% = tmpsample(1).FormulaElementFlag%
sample(1).DifferenceElementFlag% = tmpsample(1).DifferenceElementFlag%
sample(1).DifferenceFormulaFlag% = tmpsample(1).DifferenceFormulaFlag%
sample(1).StoichiometryElementFlag% = tmpsample(1).StoichiometryElementFlag%
sample(1).RelativeElementFlag% = tmpsample(1).RelativeElementFlag%
sample(1).FormulaElement$ = tmpsample(1).FormulaElement$
sample(1).FormulaRatio! = tmpsample(1).FormulaRatio!
sample(1).MineralFlag% = tmpsample(1).MineralFlag%
sample(1).DifferenceElement$ = tmpsample(1).DifferenceElement$
sample(1).DifferenceFormula$ = tmpsample(1).DifferenceFormula$
sample(1).StoichiometryElement$ = tmpsample(1).StoichiometryElement$
sample(1).StoichiometryRatio! = tmpsample(1).StoichiometryRatio!
sample(1).StoichiometryRatio! = tmpsample(1).StoichiometryRatio!
sample(1).RelativeToElement$ = tmpsample(1).RelativeToElement$
sample(1).RelativeRatio! = tmpsample(1).RelativeRatio!
End If
' Check stoichiometry assignments (only call when mode%=3 to avoid problems with formula element assignments)
If mode% = 3 Then Call GetElmCheckAssignments(sample())
If ierror Then Exit Sub
' Set background type flags (AllMANBgdFlag = true if all MAN, MANBgdFlag = true if any MAN)
sample(1).AllMANBgdFlag = True
sample(1).MANBgdFlag = False
For i% = 1 To sample(1).LastElm%
If sample(1).BackgroundTypes%(i%) = 1 Then ' 0=off-peak, 1=MAN, 2=multipoint
sample(1).MANBgdFlag = True
Else
sample(1).AllMANBgdFlag = False
End If
Next i%
Exit Sub
' Errors
AnalyzeCombineSamplesError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeCombineSamples"
ierror = True
Exit Sub
AnalyzeCombineSamplesTooManyAnalyzedElements:
msg$ = "Too many analyzed elements to combine into a single sample"
MsgBox msg$, vbOKOnly + vbExclamation, "AnalyzeCombineSamples"
ierror = True
Exit Sub
AnalyzeCombineSamplesTooManyElements:
msg$ = "Too many elements (analyzed + specified) to combine into a single sample"
MsgBox msg$, vbOKOnly + vbExclamation, "AnalyzeCombineSamples"
ierror = True
Exit Sub
End Sub
Sub AnalyzeCancel(tForm As Form)
' Cancel the analysis
ierror = False
On Error GoTo AnalyzeCancelError
tForm.StatusBarAnal.Panels(2).Bevel = sbrInset
FormPLOT.StatusBarPlot.Panels(2).Bevel = sbrInset
Call MiscTimer(CSng(0.2))
tForm.StatusBarAnal.Panels(2).Bevel = sbrRaised
FormPLOT.StatusBarPlot.Panels(2).Bevel = sbrRaised
icancelanal = True
DoEvents
Exit Sub
' Errors
AnalyzeCancelError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeCancel"
ierror = True
Exit Sub
End Sub
Sub AnalyzeNext(mode As Integer)
' Analyze the next sample
' mode = 0 disable the button
' mode = 1 enable the button
' mode = 2 set the next flag
ierror = False
On Error GoTo AnalyzeNextError
FormANALYZE.StatusBarAnal.Panels(3).Bevel = sbrInset
Call MiscTimer(CSng(0.2))
FormANALYZE.StatusBarAnal.Panels(3).Bevel = sbrRaised
' Check mode
If mode% = 0 Then
FormANALYZE.StatusBarAnal.Panels(3).Enabled = False
FormANALYZE.StatusBarAnal.Panels(3).Picture = Nothing
ElseIf mode% = 1 Then
FormANALYZE.StatusBarAnal.Panels(3).Enabled = True
Else
NextSample = True
End If
DoEvents
Exit Sub
' Errors
AnalyzeNextError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeNext"
ierror = True
Exit Sub
End Sub
Sub AnalyzeStatusAnal(astring As String)
' This routine writes the string to the status panel for analysis status purposes
ierror = False
On Error GoTo AnalyzeStatusAnalError
' Update status bar
FormANALYZE.StatusBarAnal.Panels(1).Text = astring$
DoEvents
FormPLOT.StatusBarPlot.Panels(1).Text = astring$
DoEvents
If Not RealTimeMode% Then
FormMAIN.StatusBarAuto.Panels(1).Text = astring$
DoEvents
End If
Exit Sub
' Errors
AnalyzeStatusAnalError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeStatusAnal"
ierror = True
Exit Sub
End Sub
Sub AnalyzeNextToggle()
' Toggle the Next button for attention
ierror = False
On Error GoTo AnalyzeNextToggleError
If TimerToggle Then
FormANALYZE.StatusBarAnal.Panels(3).Picture = FormANALYZE.CommandNext.Picture
Else
FormANALYZE.StatusBarAnal.Panels(3).Picture = Nothing
End If
TimerToggle = Not TimerToggle
DoEvents
Exit Sub
' Errors
AnalyzeNextToggleError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeNextToggle"
ierror = True
Exit Sub
End Sub
Sub AnalyzeSelectSamples(tList As ListBox)
' Select the selected samples in the list (include "continued" samples)
ierror = False
On Error GoTo AnalyzeSelectSamplesError
Dim i As Integer, n As Integer
' Save original selected sample
n% = tList.ListIndex
'tList.Enabled = False ' commented out to avoid problem in FormPLOT_WAVE loading X and Y lists
'DoEvents
' Select all sample after selected sample
For i% = n% + 1 To tList.ListCount - 1
If InStr(tList.List(i%), CONTINUED$) Then
tList.Selected(i%) = True
Else
Exit For
End If
Next i%
' Select all samples backwards
If InStr(tList.List(n%), CONTINUED$) Then
For i% = n% - 1 To 0 Step -1
If InStr(tList.List(i%), CONTINUED$) Then
tList.Selected(i%) = True
Else
Exit For
End If
Next i%
tList.Selected(i%) = True
End If
'tList.Enabled = True ' commented out to avoid problem in FormPLOT_WAVE loading X and Y lists
'DoEvents
Exit Sub
' Errors
AnalyzeSelectSamplesError:
MsgBox Error$, vbOKOnly + vbCritical, "AnalyzeSelectSamples"
tList.Enabled = True
ierror = True
Exit Sub
End Sub