vbscript 多层次“智能”关键字搜索(VBS)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 多层次“智能”关键字搜索(VBS)相关的知识,希望对你有一定的参考价值。
<af name="Custom_SSNSearch" access="public" bInter="bInter" bDebug="bDebug" strParam="StrParam" >
<g>
<![CDATA[
Custom_SSNSearch = False
If (CurrentObj.ObjectType<>3) Then
Exit Function 'must be a field
End if
Dim keyArray
Dim sList
Dim ReadKeyFile
Dim sExtn
Dim foundKeyWord
Dim foundSSN
Dim foundNumber
Dim found
found = false
foundSSN = false
foundNumber = false
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const CreateNew = True, DoNotCreate = False
Const SysDefault = -2, OpenAsUnicode = -1, OpenAsASCII = 0
ReadKeyFile = ""
sExtn = ".key"
StrParam = Trim(StrParam)
If NOT Right(lcase(StrParam),4)=sExtn then
'Add the '.key' extension for file i/o compatibility
StrParam = StrParam & sExtn
End if
strPath = Pilot.ProjectPath
strProcessDir = FileMgr.GetParentFolderName(strPath) & "\"
sPathedParam = Trim(strProcessDir & strParam)
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(sPathedParam) then
Set oKeyFile = FileMgr.OpenTextFile(sPathedParam, ForReading, DoNotCreate, OpenAsASCII)
If oKeyFile.AtEndOfStream = False Then
sList = oKeyFile.ReadAll
Writelog("Opened and read key file: " & sPathedParam)
keyArray = Split(sList,vbCrLf)
End if
oKeyFile.Close
End If
For each x in keyArray
if x <> " " then
CurrentObj.Text = ""
Writelog("Looking for keyword: " & x)
found = WordFind(false,false,Trim(x))
if found then
Writelog("Found keyword: " & x & " now look beside it.")
Call GoRightWord(false,false,"1")
Call GroupNextWords(false,false,"1")
Call UpdateField(false,false)
foundNumber = IsNumber(false,false,"80")
foundSSN = IsFieldLengthMin(false,false,"9")
if foundNumber And foundSSN then
Writelog("Found a valid SSN beside the keyword.")
CurrentObj.Parent.Variable("FoundEmployeeSSN") = "True"
exit function
else
CurrentObj.Text = ""
Writelog("Found keyword: " & x & " now look below it.")
Call WordFind(false,false,Trim(x))
Call GoBelowWord(false,false,"1")
Call GroupNextWords(false,false,"1")
Call UpdateField(false,false)
foundNumber = IsNumber(false,false,"80")
foundSSN = IsFieldLengthMin(false,false,"9")
if foundNumber And foundSSN then
Writelog("Found a valid SSN below the keyword.")
CurrentObj.Parent.Variable("FoundEmployeeSSN") = "True"
exit function
else
CurrentObj.Text = ""
Writelog("Found keyword: " & x & " now look above it.")
Call WordFind(false,false,Trim(x))
Call GoAboveWord(false,false,"1")
Call GroupNextWords(false,false,"1")
Call UpdateField(false,false)
foundNumber = IsNumber(false,false,"80")
foundSSN = IsFieldLengthMin(false,false,"9")
if foundNumber And foundSSN then
Writelog("Found a valid SSN above the keyword.")
CurrentObj.Parent.Variable("FoundEmployeeSSN") = "True"
exit function
else
Writelog("Didn't find a valid SSN beside, below, or above the keyword. Move to next keyword.")
CurrentObj.Text = ""
end if
end if
end if
end if
end if
Next
]]></g></af>
以上是关于vbscript 多层次“智能”关键字搜索(VBS)的主要内容,如果未能解决你的问题,请参考以下文章