vbscript 它是一个脚本定位器,​​用于评估两个备选集合的接近程度,并从第二个lis返回一系列备选方案

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 它是一个脚本定位器,​​用于评估两个备选集合的接近程度,并从第二个lis返回一系列备选方案相关的知识,希望对你有一定的参考价值。

Private Sub ScrRelations_LocateAlternatives(ByVal pXDoc As CASCADELib.CscXDocument, ByVal pLocator As CASCADELib.CscXDocField)
   Dim oAlts1 As CscXDocFieldAlternatives
   Dim oAlts2 As CscXDocFieldAlternatives
   Dim arrAlts() As CscXDocFieldAlternative
   Dim oAlt As CscXDocFieldAlternative
   Dim oNewAlt As CscXDocFieldAlternative
   Dim i As Long

   Set oAlts1 = pXDoc.Locators.ItemByName("FmtCrownAgents").Alternatives
   Set oAlts2 = pXDoc.Locators.ItemByName("FmtNumbers").Alternatives
   arrAlts = EvaluateAlternativesRelationships(oAlts1, oAlts2, 1, 10)

   For i = LBound(arrAlts) To UBound(arrAlts)
      Set oAlt = arrAlts(i)

      If oAlt Is Nothing Then
         Exit For
      End If

      Set oNewAlt = pLocator.Alternatives.Create()
      oNewAlt.Confidence = oAlt.Confidence
      oNewAlt.Height = oAlt.Height
      oNewAlt.Left = oAlt.Left
      oNewAlt.Text = oAlt.Text
      oNewAlt.Top = oAlt.Top
      oNewAlt.Width = oAlt.Width
   Next
End Sub

Private Function EvaluateAlternativesRelationships(ByVal alts1 As CscXDocFieldAlternatives, ByVal alts2 As CscXDocFieldAlternatives, _
                                                   ByVal minLineDistance As Long, ByVal maxLineDistance As Long) As CscXDocFieldAlternative()
   Dim i As Long
   Dim j As Long
   Dim lAltsIndex As Long
   Dim arrAlts() As CscXDocFieldAlternative
   Dim oAlt1 As CscXDocFieldAlternative
   Dim oAlt2 As CscXDocFieldAlternative
   Dim lAlt1Line As Long
   Dim lAlt2Line As Long
   Dim lLineDistance As Long

   ReDim arrAlts(99)
   lAltsIndex = -1

   For i = 0 To alts1.Count - 1
      Set oAlt1 = alts1.ItemByIndex(i)

      If oAlt1.Words.Count > 0 Then
         lAlt1Line = oAlt1.Words.ItemByIndex(0).LineIndex

         For j = 0 To alts2.Count - 1
            Set oAlt2 = alts2(j)

            If oAlt2.Words.Count > 0 Then
               lAlt2Line = oAlt2.Words.ItemByIndex(0).LineIndex
               lLineDistance = lAlt2Line - lAlt1Line

               If lLineDistance >= minLineDistance And lLineDistance <= maxLineDistance Then
                  lAltsIndex = lAltsIndex + 1

                  If lAltsIndex > UBound(arrAlts) Then
                     ReDim Preserve arrAlts(UBound(arrAlts) + 99)
                  End If

                  Set arrAlts(lAltsIndex) = oAlt2
               End If
            End If
         Next
      End If
   Next

   If lAltsIndex > -1 And lAltsIndex < UBound(arrAlts) Then
      ReDim Preserve arrAlts(lAltsIndex)
   End If

   EvaluateAlternativesRelationships = arrAlts
End Function

以上是关于vbscript 它是一个脚本定位器,​​用于评估两个备选集合的接近程度,并从第二个lis返回一系列备选方案的主要内容,如果未能解决你的问题,请参考以下文章

评估COM接口返回的非变量数组引起的VBScript类型不匹配错误可以通过更改语言来解决吗?

vbscript 一个VBS脚本,用于监视打印队列和电子邮件,如果任何单个作业已经存在超过15分钟

vbscript 用于从财务代码中提取出生日期+性别...的VBA脚本

VBScript 执行和评估命令

ZTIGather.wsf 是 MDT (Microsoft Deployment Toolkit) 中的一个 VBScript 脚本,用于在部署过程中收集有关目标计算机硬件和软件环境的信息,并将这些

用于移动类似文件的 VBScript