Addons/general/pcall/test comcall

From J Wiki
Jump to navigation Jump to search
   require 'general/pcall/ole32'
   coinsert 'pole32'

   'IJ_'idef IJ=: IDispatch,;:;<;._2(0 : 0)
  Do Show Log IsBusy Break Quit Get Set GetM SetM ErrorText
  ErrorTextM Clear Transpose ErrorTextB GetB SetB DoR
)
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

   ijDoR=:         [:'ci3 > i i i *w *i *i' pcall IJ_DoR ; ;

   h J=.CreateObject 'JDLLServer'
10B4018

   res=. VariantAlloc ''               NB. alloc VARIANT for BSTR

   J ijDoR '9!:14$0' ; res ; ,_2
0

   VariantStr res                      NB. BSTR string value
j601/2006-11-17/17:05


   VariantClear <res  NB. free BSTR, 'cause we own it
0

   h IT=.{.IT [  J idGetTypeInfo 0 ; 0 ; IT=.,_2
ACBC4

   IT itGetTypeAttr pta=. ,_2
0
   ] cf=. (TYPEATTR si 'Cf') mS pta    NB. count of functions in J interface
25
   #IJ
25
   IT itReleaseTypeAttr {.pta
96

   IT GetDoc _1                        NB. type name
+-----------+--------------------------------+
|IJDLLServer|Jsoftware : JDLLServer Interface|
+-----------+--------------------------------+

   }:; IT <@(LF ,~ ;:^:_1)@FuncDesc (#IDispatch)([+i.@-~)cf
long Do BSTR input
long Show long b
long Log long b
long IsBusy
long Break
long Quit
long Get BSTR jname VARIANT* v
long Set BSTR jname VARIANT* v
long GetM BSTR jname long* jtype long* jrank long* jshape long* jdata
long SetM BSTR jname long* jtype long* jrank long* jshape long* jdata
long ErrorText long error VARIANT* v
long ErrorTextM long error long* text
long Clear
long Transpose long b
long ErrorTextB long error VARIANT* v
long GetB BSTR jname VARIANT* v
long SetB BSTR jname VARIANT* v
long DoR BSTR input VARIANT* v

   IT FuncDoc IJ_DoR
+---+---------------------------------------------------+
|DoR|Execute string and return formatted output in BSTR.|
+---+---------------------------------------------------+

   IT iuRelease ''
1

   J iuRelease ''                      NB. destroys J object, RefCount=0
0