阅读背景:

Array loses values after loop in Vbscript

来源:互联网 

This is the code:

这是代码:

'creates the msxml object
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
Dim retVal

'load the xml data of the script
retVal=xmlDoc.load(argFilePath)

Dim fso, folder, sFolder
Dim xmlDataPath, curNode

'get input folder
Set curNode=xmlDoc.selectSingleNode("//ScriptXmlData/inputFilePath")
Dim inputFolder, outputFolder, hotLoc
inputFolder=CSTR(curNode.text)

'location of jdf files
sFolder=inputFolder

'creating file getting object
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(sFolder)

Dim amount, fName, arrC, i
i=0

'loop for getting amounts
For each folderIdx In folder.files
    If fso.GetExtensionName(folderIdx.Name) = "jdf" Then

        'increase array size
        Redim arrC(i)

        'get folder name
        fName=folderIdx.Name

        'get file path
        xmlDataPath = sFolder+"\"+fName

        'load the xml data of the script
        retVal = jdfDoc.load(xmlDataPath)

        'get amount
        Set curNode = jdfDoc.selectSingleNode("//jdf:JDF/jdf:ResourceLinkPool/jdf:ComponentLink")
        amount = curNode.getAttribute("Amount")

        'Create array that holds amount
        arrC(i)=amount
        i=i+1

    End If
Next

wscript.echo arrC(0)
wscript.echo arrC(1)
wscript.echo arrC(2)
'creates the msxml 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: