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)
Our problem is that once arrC exits the loop, some of its values go missing. For example, inside the loop our array is:
arrC(0)=100
arrC(1)=150
arrC(2)=200
Once it leaves the loop, as in the test in the end of the code, its values are :
arrC(0)=""
arrC(1)=""
arrC(2)=200
Can someone please explain?
Thank you!