C++ カスタム コマンドが配列を戻すとき、呼び出し側が受け取る値は、スクリプト言語によって、また、CValueArray と CRefArray のどちらが戻されるかによって決まります。たとえば、コマンドが CValueArray を戻す場合、JScript の呼び出し側は安全な配列を取得しますが、コマンドが CRefArray を戻す場合、JScript の呼び出し側は XSICollection を取得します。
言語 |
CRefArray |
CValueArray |
---|---|---|
VBScript |
XSICollection |
XSICollection |
JScript |
XSICollection |
safe array |
Python |
XSICollection のインスタンス |
tuple |
// // GetValueArray() is a C++ custom command that returns a CValueArray // var aSafeArray = GetValueArray(); var aVBArray = new VBArray( aSafeArray ); logmessage( typeof( aVBArray ) ); logmessage( aVBArray.dimensions() ); // Access the VBArray directly for (var i=0; i <= aVBArray.ubound(1); i++) { Application.LogMessage( aVBArray.getItem(i).fullname ); } // Convert the VBArray to a JScript array var aJSarray = aVBArray.toArray(); for (e=new Enumerator(aJSarray);!e.atEnd();e.moveNext()) { var o = e.item(); logmessage( o.fullname ); } // // GetRefArray() is a C++ custom command that returns a CRefArray // var objects = GetRefArray(); logmessage( objects.type ); //INFO : XSICollection for (e=new Enumerator(objects);!e.atEnd();e.moveNext()) { var o = e.item(); Application.LogMessage( o.fullname ); }
# # GetValueArray is a C++ custom command that returns a CValueArray # objects = Application.GetValueArray() Application.Logmessage( unicode(type(objects)) )#INFO : <type 'tuple'> for o in objects: Application.LogMessage( o.name ) Application.Logmessage( unicode(type(o)) )#INFO : <type 'instance'> Application.LogMessage( Application.classname(o) ) # # GetRefArray is a C++ custom command that returns a CRefArray # objects = Application.GetRefArray() Application.Logmessage( unicode(type(objects)) )#INFO : <type 'instance'> Application.Logmessage( objects.type )# XSICollection for o in objects: Application.LogMessage(o.name) for i in range(objects.Count): Application.LogMessage(objects(i).FullName)
' ' GetValueArray() returns a CValueArray ' set objects = GetValueArray() logmessage( typename( objects ) )'INFO : Object logmessage( objects.type )'INFO : XSICollection for each o in objects logmessage o.name next ' ' GetRefArray() returns a CRefArray ' set objects = GetRefArray() logmessage typename( objects )'INFO : Object logmessage( objects.type )'INFO : XSICollection for each o in objects logmessage o.name next