Created
October 7, 2011 08:54
-
-
Save taka2/1269817 to your computer and use it in GitHub Desktop.
1次元のJScript配列を、1次元のSafeArrayに変換するサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="Shift_JIS" ?> | |
| <package> | |
| <job> | |
| <script language="VBScript"><![CDATA[ | |
| ' 1次元のJScript配列を、1次元のSafeArrayに変換する関数 | |
| Function convertToSafeArray(jsArray) | |
| Dim length, result(), elem, i | |
| length = jsArray.length | |
| ReDim result(length-1) | |
| For i=1 to length | |
| elem = jsArray.shift() | |
| result(i-1) = elem | |
| Next | |
| convertToSafeArray = result | |
| End Function | |
| ]]></script> | |
| <script language="JScript"><![CDATA[ | |
| // 1次元のJScript配列 | |
| var arr = [1,3,6]; | |
| // SafeArrayに変換 | |
| var safeArray = convertToSafeArray(arr); | |
| printVBArray(new VBArray(safeArray)); | |
| // デバッグ用:VBArrayを表示 | |
| function printVBArray(vbArray) { | |
| for(var i=0; i<=vbArray.ubound(1); i++) { | |
| WScript.Echo("vbArray[" + i + "] = " + vbArray.getItem(i)); | |
| } | |
| } | |
| ]]></script> | |
| </job> | |
| </package> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment