这很奇怪:当textFile是硬编码时,双击[输出(拆分)弧文件]运行时脚本运行正常.将文件拖放到脚本上时,没有错误,也没有输出文件.使用拖放时脚本肯定会运行,我在writeTo之前的行中添加了一个简单的消息框,以确认它确实达到了这一点.拖放时没有文件输出,只有当textFile被硬编码时才能正常工作.有人请帮忙!
if WScript.Arguments.Count <> 0 then
textFile = WScript.Arguments(0)
else
textFile = "multi2.txt"
end if
saveTo = ""
writeTo = ""
strNewLine = "%_N_"
headingPattern = "(%_N_)"
dim fileFrom, regex, fileTo
Set fso = CreateObject("Scripting.FileSystemObject")
set fileFrom = fso.OpenTextFile(textFile)
set regex = new RegExp
set fileTo = nothing
with regex
.Pattern = headingPattern
.IgnoreCase = false
.Global = true
end with
while fileFrom.AtEndOfStream <> true
line = fileFrom.ReadLine
set matches = regex.Execute(line)
if matches.Count > 0 then
strCheckForString = UCase("%") …Run Code Online (Sandbox Code Playgroud)