VbScript:函数未完全执行

时间:2013-03-28 18:41:07

标签: function vbscript

我正在尝试调用一个函数。内部函数我正在读取一个xml文件并将值更改为其中一个节点。但它在行sXmlFile = OpenXMLFile("\\common_automation\common_bin\" & sXmlFileName & ".xml")

之后退出了函数

单独测试时功能内部的功能正常。但是我如何使控制转到整个功能而不退出。在第1次调用中完全执行函数语句之前,它将第2次调用函数。

x=replace_instrument_id(strIp,"newFund")
y=replace_instrument_id(strIp,"newBlock")
z=replace_instrument_id(strIp,"newSecRef")

Function replace_instrument_id(sCusip,sXmlFileName)
WScript.Echo"sCusip:" & sCusip
WScript.Echo"sXmlFileName:" & sXmlFileName
sXmlFile = OpenXMLFile("\\common_automation\common_bin\" & sXmlFileName & ".xml")
WScript.Echo "sXmlFile" & sXmlFile
strCusip = sCusip

Dim sNS    : sNS      = "xmlns:xs='http://www.w3.org/2001/XMLSchema'  xmlns:msdata='urn:schemas-microsoft-com:xml-msdata'"
Dim oXDoc  : Set oXDoc = CreateObject( "Msxml2.DOMDocument.6.0" )
Dim sXPath 

if(sXmlFileName="newSecRef") Then
   sXPath    = "/NewDataSet/ReturningDataSet/live_ins_id"
Else
   sXPath    = "/NewDataSet/ReturningDataSet/ins_id"
End If
  oXDoc.setProperty "SelectionLanguage", "XPath"
  oXDoc.setProperty "SelectionNamespaces", sNS
  oXDoc.async = False
  oXDoc.loadXml  sXmlFile

   If 0 = oXDoc.ParseError Then
     oXDoc.selectSingleNode(sXPath).text = strCusip
     oXDoc.save "\common_automation\common_bin\"& sXmlFileName &".xml"
     WScript.Echo oXDoc.selectSingleNode(sXPath).text
  Else
    WScript.Echo oXDoc.parseError.reason
  End If
End Function

Function OpenXMLFile (filename)
    Set objFSO = CreateObject("Scripting.FileSystemObject") 
    Set objFile = objFSO.OpenTextFile(filename, 1) 
    thisline = objFile.ReadAll
    objFile.Close
    OpenXMLFile = thisline
End Function

我得到的输出是

sCusip:02R99BET7
sXmlFileName:newFund
sCusip:02R99BET7
sXmlFileName:newBlock
sCusip:02R99BET7
sXmlFileName:newSecRef

0 个答案:

没有答案