;========================================================================================================================================== ; ; How to exchange an array between Winbatch, VBScript, JScript? ; ;========================================================================================================================================== objJSC = CreateObject ("MSScriptControl.ScriptControl") objJSC.Language = "JScript" objJSC.AllowUI = @FALSE objVBSC = CreateObject ("MSScriptControl.ScriptControl") objVBSC.Language = "VBScript" objVBSC.AllowUI = @FALSE ; VBScript. ; Create empty Dim-1 array in VB. ; "Import" the array from VB into WB as return value from VBScript function "My_VBS_Function()". objVBSC.AddCode(: "Function My_VBS_Function ()" : @LF : "Dim arr(2)" : @LF : "My_VBS_Function = arr" : @LF : "End Function") arrVB = objVBSC.Run(: "My_VBS_Function") ; WB. intDims = ArrInfo (arrVB, 0) intElements = ArrInfo (arrVB, 1) Terminate (intElements == 0, "Terminated.", "No elements ... nothing to do.") intElem = 0 ForEach arrElement In arrVB Message ("WB|VB Array|Element: " : intElem, "Content: " : arrElement) ; Array elements are empty. intElem = intElem + 1 Next intElemLast = intElements - 1 For intElem = 0 To intElemLast arrVB[intElem] = Num2Char (65 + intElem) ; Set array elements. Message ("WB|VB Array|Element: " : intElem, "Content: " : arrVB[intElem]) Next intElem = 0 ForEach arrElement In arrVB arrVB[intElem] = ItemExtract (1 + intElem, "red,green,blue,black,white", ",") ; Set array elements. Message ("WB|VB Array|Element: " : intElem, "Content: " : arrVB[intElem]) intElem = intElem + 1 Next ; JScript. ; "Export" the array from WB to JS as parameter of the JScript function "My_JS_Function()". ; "Import" the array from JS into WB as return value from JScript MyFunction. objJSC.AddCode("function My_JS_Function(Arg){return Arg;}") arrJS = objJSC.Run(: "My_JS_Function", arrVB) ; WB. intDims = ArrInfo (arrJS, 0) intElements = ArrInfo (arrJS, 1) Terminate (intElements == 0, "Terminated.", "No elements ... nothing to do.") intElem = 0 ForEach arrElement In arrJS Message ("WB|JS Array|Element: " : intElem, "Content: " : arrElement) intElem = intElem + 1 Next DropWild ("obj*") Exit