-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathvalve_node_cb.bas
More file actions
executable file
·92 lines (66 loc) · 2.07 KB
/
valve_node_cb.bas
File metadata and controls
executable file
·92 lines (66 loc) · 2.07 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
public sub OnBeginRecordNode
if Importer.Field("d_operatio") = "Abandoned" or Importer.Field("d_operatio") = "Proposed" then
Importer.WriteRecord = false
end if
end sub
public sub OnEndRecordNode
diameter = DiameterToNum(Importer.Field("d_diameter"))
Importer.Field("user_text_9") = diameter
If Importer.Field("d_type") = "Pressure Reducing" or Importer.Field("d_type") = "Pressure Sustaining" Then
Importer.Field("user_text_10") = "PLUG"
Importer.Field("user_text_10_flag") = "AV"
ElseIf Importer.Field("d_mechanis") = "Sluice" or Importer.Field("d_mechanis") = "Gate" Then
Importer.Field("user_text_10") = "GATE"
Importer.Field("user_text_10_flag") = "IG"
Else
Importer.Field("user_text_10") = "GATE"
Importer.Field("user_text_10_flag") = "AV"
End If
end sub
Private Function DiameterToNum(dia)
Dim postfix
postfix = Right(dia, 2)
Select Case postfix
Case "mm"
'strip mm
DiameterToNum = Left(dia, Len(dia) - 2)
Case "in"
'Concert inch to mm
DiameterToNum = InchToMM(dia)
Case "wn","er"
'Unkown or Other
DiameterToNum = ""
Case Else
'Assume empty
DiameterToNum = dia
End Select
End Function
Private Function InchToMM(dia)
Dim fraction
fraction = 0
Dim fractionPosition
fractionPosition = InStr(dia, "/")
Dim trimCount
trimCount = 2
If fractionPosition > 0 Then
'Found Fraction
Dim fractionString
fractionString = Mid(dia, fractionPosition - 1, 3)
Select Case fractionString
Case "1/2"
fraction = 0.5
Case "1/4"
fraction = 0.25
End Select
trimCount = 5
End If
Dim leftNumber
leftNumber = Left(dia, Len(dia) - trimCount)
Dim finalNumber
If IsNumeric(leftNumber) Then
finalNumber = CDbl(leftNumber)
Else
finalNumber = 0
End If
InchToMM = (finalNumber + fraction) * 25.4
End Function