Function filter_a_sentence(string_tmp)
' 本模块是处理一个句子
array_a = Split(string_tmp, ";")
string_number = UBound(array_a)
For index = 0 To string_number - 1
string_tmp = array_a(index)
position = InStr(1, string_tmp, "-")
array_a(index) = Left(string_tmp, position - 1)
Next
filter_a_sentence = Join(array_a, " ")
End Function
sub filter_a_file(Filepath_in, Filepath_out)
' 本模块是处理一个文件
set fso1=createobject("scripting.filesystemobject")
set file1=fso1.opentextfile(Filepath_in)
set file2=fso1.createtextfile(Filepath_out)
do
newline=file1.readline
if instr(trim(newline),";")>0 then file2.writeline filter_a_sentence(newline)
loop until file1.atEndOfStream
file1.close
file2.close
set file1=nothing
set file2=nothing
set fso1=nothing
End sub
附录二 语法标志过滤器 自动版.vbs的源代码
filter_a_file ".\input.txt",".\output.txt"
Function filter_a_sentence(string_tmp)
' 本模块是处理一个句子
array_a = Split(string_tmp, ";")
string_number = UBound(array_a)
For index = 0 To string_number - 1
string_tmp = array_a(index)
position = InStr(1, string_tmp, "-")
array_a(index) = Left(string_tmp, position - 1)
Next
filter_a_sentence = Join(array_a, " ")
End Function
sub filter_a_file(Filepath_in, Filepath_out)
' 本模块是处理一个文件
set fso1=createobject("scripting.filesystemobject")
set file1=fso1.opentextfile(Filepath_in)
set file2=fso1.createtextfile(Filepath_out)
do
newline=file1.readline
if instr(trim(newline),";")>0 then file2.writeline filter_a_sentence(newline)
loop until file1.atEndOfStream
file1.close
file2.close
set file1=nothing
set file2=nothing
set fso1=nothing
End sub
Function filter_a_sentence(string_tmp)
' 本模块是处理一个句子
array_a = Split(string_tmp, ";")
string_number = UBound(array_a)
For index = 0 To string_number - 1
string_tmp = array_a(index)
position = InStr(1, string_tmp, "-")
array_a(index) = Left(string_tmp, position - 1)
Next
filter_a_sentence = Join(array_a, " ")
End Function
sub filter_a_file(Filepath_in, Filepath_out)
' 本模块是处理一个文件
set fso1=createobject("scripting.filesystemobject")
set file1=fso1.opentextfile(Filepath_in)
set file2=fso1.createtextfile(Filepath_out)
do
newline=file1.readline
if instr(trim(newline),";")>0 then file2.writeline filter_a_sentence(newline)
loop until file1.atEndOfStream
file1.close
file2.close
set file1=nothing
set file2=nothing
set fso1=nothing
End sub
Function filter_a_sentence(string_tmp)
' 本模块是处理一个句子
array_a = Split(string_tmp, ";")
string_number = UBound(array_a)
For index = 0 To string_number - 1
string_tmp = array_a(index)
position = InStr(1, string_tmp, "-")
array_a(index) = Left(string_tmp, position - 1)
Next
filter_a_sentence = Join(array_a, " ")
End Function
sub filter_a_file(Filepath_in, Filepath_out)
' 本模块是处理一个文件
set fso1=createobject("scripting.filesystemobject")
set file1=fso1.opentextfile(Filepath_in)
set file2=fso1.createtextfile(Filepath_out)
do
newline=file1.readline
if instr(trim(newline),";")>0 then file2.writeline filter_a_sentence(newline)
loop until file1.atEndOfStream
file1.close
file2.close
set file1=nothing
set file2=nothing
set fso1=nothing
End sub
附录五 语法标志过滤器 EXE版.exe的源代码
Function filter_a_sentence(string_tmp)
' 本模块是处理一个句子
array_a = Split(string_tmp, ";")
string_number = UBound(array_a)
For Index = 0 To string_number - 1
string_tmp = array_a(Index)
position = InStr(1, string_tmp, "-")
array_a(Index) = Left(string_tmp, position - 1)
Next
filter_a_sentence = Join(array_a, " ")
End Function
Sub filter_a_file(Filepath_in, Filepath_out)
' 本模块是处理一个文件
Open Filepath_in For Input As #1
Open Filepath_out For Output As #2
Do
Line Input #1, newline
If InStr(Trim(newline), ";") > 0 Then Print #2, filter_a_sentence(newline)
Loop Until EOF(1)
Close #1, #2
End Sub
Private Sub Command1_Click()
If Right(File1.Path, 1) <> "\" Then
filter_a_file File1.Path & "\" & File1.FileName, File1.Path & "\" & "output.txt"
Else
filter_a_file File1.Path & File1.FileName, File1.Path & "output.txt"
End If
MsgBox "结果已经保存到当前文件夹的output.txt!", vbInformation, "处理完毕"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub