我有一个如下的属性文件:
FileToRead=project.xml,CheckFile.ini RunTimeFile=MyRuntime.xml
我想通过使用VBScript的FileToRead
循环来逐一读取参数For
的逗号分隔值。
我已经尝试过如下脚本进行测试的脚本:
Set fso = CreateObject("Scripting.FileSystemObject")
Const ForReading = 1
Const ForWriting = 2
listFile = fso.OpenTextFile("MyFile.properties").ReadLine
listcheck = Split(listFile, vbCrLf)
For Each MyValue In listcheck
segments = Split(line, ",")
WScript.Echo "SimpleCheck"
Next
是否有可能在VBS的Or
块内使用If
条件?
答案 0 :(得分:1)
您可以使用类似的
Set fso = CreateObject("Scripting.FileSystemObject")
'Dictionary to store all the lines in form of key value pair
Set dict = CreateObject("Scripting.Dictionary")
Set file = fso.OpenTextFile ("<InputFilePath>", 1)
'Reading the file and storing properties in the dictionary
Do Until file.AtEndOfStream
line = file.Readline
splittedLine = Split(line,"=")
if UBound(splittedLine)=1 then
dict.Add splittedLine(0),splittedLine(1)
end if
Loop
file.Close
'Now get the value from dictionary using key name FileToRead
valFileToRead = dict.item("FileToRead")
arrFiles=Split(valFileToRead,",")
for i=0 to UBound(arrFiles)
'Do anything with the values
msgBox(arrFiles(i))
next
是的,您可以在内部使用OR
关键字
if Condition1 OR Condition 2 then
'Code
end if