Function PrefixTest() As Integer
' Find prefixes and combinations of prefixes and units which cannot be parsed by the conversion program.
Const strFn = "PrefixTest"
Debug.Print strFn & ": Info: Begin " & Time
'' Assume that the definitions are valid; will reset return value to False when
'' and if errors are found in the definitions.
PrefixTest = True
InitializeMaybe
Dim lngCurPre As Long
For lngCurPre = 1 To GetPrefixCount
If estBE.TrueEveryNSeconds(30) Then
Debug.Print strFn & ": Info: checking prefix #" & lngCurPre & " of " & GetPrefixCount & " " & Time
End If
Dim strPreCode As String
Dim strPreCodeStr As String
Dim strPreName As String
Dim dblPreExp As Double
Dim dblCurExp As Double
If Not GetPrefix(lngCurPre, strPreCode, strPreCodeStr, strPreName, dblPreExp) Then
PrefixTest = False
Exit Function
End If
'' Try parsing the prefix code itself.
Dim varRtn As Variant
varRtn = ConvertMeasure(1, strPreCode, "")
If IsNull(varRtn) Or InStr(1, varRtn, ":", vbBinaryCompare) <> 0 Then
Debug.Print strFn & ": Error: error parsing " & strPreCode & "; definition: " & dblPreExp & "; result: " & varRtn
PrefixTest = False
End If
'' Try parsing the randomly-capitalized version of the prefix code.
Dim strPrefixCode As String
strPrefixCode = estSE.RandomCapitalize(strPreCode)
varRtn = ConvertMeasure(1, strPrefixCode, "")
If IsNull(varRtn) Or InStr(1, varRtn, ":", vbBinaryCompare) <> 0 Then
Debug.Print strFn & ": Error: error parsing randomly capitalized " & strPrefixCode & "; definition: " & dblPreExp & "; result: " & varRtn
PrefixTest = False
End If
'' When unit definitions have been loaded, parse the combination of the current prefix with a ramdomly chosen unit.
If GetUnitCount > 0 Then
Dim lngRand As Long
lngRand = estRV.RandomLongWithinRangeFast(1, GetUnitCount)
Dim strCurCode As String
If Not GetUnit(lngRand, strCurCode) Then
PrefixTest = False
Exit Function
End If
strPrefixCode = strPreCode + strCurCode
varRtn = ConvertMeasure(1, strPrefixCode, "")
If IsNull(varRtn) Or InStr(1, varRtn, ":", vbBinaryCompare) <> 0 Then
Debug.Print strFn & ": Error: error parsing prefix and random unit " & strPrefixCode & "; result: " & varRtn
PrefixTest = False
End If
End If
Next lngCurPre
Debug.Print strFn & ": Info: End " & Time
End FunctionCopyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.