To validate rules for intercompany transactions, load the rules with SetVBScriptRules2. |
SetVBScriptRules returns arrays that contain the line numbers, severity levels, descriptions, contents, and details of the lines in a rules file that do not pass validation. These arrays have a one-to-one correspondence, with one item for each line that does not pass validation.
Variables cannot be tested for validity, so whenever SetVBScriptRules encounters a line containing a variable, items with a severity level of Information are included in the arrays. The descriptions for these lines say that “validation was not performed.” |
<HsvCalculate>.SetVBScriptRules varabRules, vbScanOnly, pvbErrorsWereFound, pvbWarningsWereFound, pvbInfoWasProvided, pvaralErrorLineNumbers, pvaralErrorSeverity, pvarabstrErrorDescriptions, pvarabstrErrorVBScript, pvarabstrErrorDetails
The following example creates a log file that lists the line numbers, descriptions, and details for any validation messages of a warning severity level. Various Visual Basic methods convert the rules file to an array of bytes, which is then passed to SetVBScriptRules; note that SetVBScriptRules is set to scan. If the pvbWarningsWereFound argument returns TRUE, the example loops through the pvaralErrorSeverity argument array to find items flagged with a warning severity level. For each such item, the corresponding items returned in the pvaralErrorLineNumbers, pvarabstrErrorDescriptions, and pvarabstrErrorDetails arguments are concatenated to the vLogText variable. When the loop finishes, vLogText’s value is written to the log file, which is created by using various Visual Basic methods.
Dim cCalculate As HsvCalculate, vFileName, lFile As Long
Dim lSize As Long, vaRules, bytaRules() As Byte
Dim bErrs As Boolean, bWarnings As Boolean, bInfo As Boolean
Dim valLines, valSeverity, vasDescs, vasErr, vasDetails
Dim vLogText, iFile As Integer
Set cCalculate = m_cHsvSession.Calculate
vFileName = "C:\Program Files\Acme\AppRules.rle"
lFile = FreeFile
lSize = FileLen(vFileName)
Open vFileName For Binary Access Read As #lFile
ReDim bytaRules(lSize)
Get #lFile, , bytaRules
Close #lFile
vaRules = bytaRules
cCalculate.SetVBScriptRules vaRules, True, bErrs, bWarnings, _
bInfo, valLines, valSeverity, vasDescs, vasErr, vasDetails
If bWarnings = True Then
For i = LBound(valLines) To UBound(valLines)
If valSeverity(i) = 2 Then
vLogText = vLogText & "Line #: " & valLines(i) & _
vbCrLf & " Description: " & vasDescs(i) & vbCrLf _
& " Details: " & vasDetails(i) & vbCrLf & vbCrLf
End If
Next i
iFile = FreeFile
Open "C:\Program Files\Acme\warnings.log" For Output As #iFile
Print #iFile, vLogText
Close #iFile
End If