From: Mark M. <mie...@ac...> - 2007-02-12 05:54:08
|
[You probably need to read the first e-mail for this to make sense.] As I said previously, I first envisioned OLEVariant to be a simple, quickly discarded class, used mostly as a flag. Rony came up with an idea that makes it more useful in the case of an out parameter. The idea is to return the out parameter in the OLEVariant object rather than in a separate array. Then, the OLEVariant object could be used as the returned object. This would be done by the wrapper object (the OLEObject) delegating messages (method calls) to the returned out parameter object. Using a previous example where the process ID of a started process is returned as an out parameter. This would be the code using OLEVariant as a simple object: objProcess = .oleObject~GetObject("WinMgmts:Win32_Process") pid = .OLEVariant~new( VT_I4, 0, "IN,OUT" ) ret = objProcess~Create('notepad.exe', .nil, .nil, pid) If ret == 0 then do outParms = objProcess~GetOutParameters if outParms <> .nil then do say 'The created process ID is:' outParms~at(1) 'taskkill /PID' outParms~at(1) end end That code, using OLEVariant as I now see it would be: objProcess = .oleObject~GetObject("WinMgmts:Win32_Process") pid = .OLEVariant~new( VT_I4, 0, "IN,OUT" ) ret = objProcess~Create('notepad.exe', .nil, .nil, pid) If ret == 0 then do say 'The created process ID is:' pid 'taskkill /PID' pid end Rony likes that a lot, and so do I. <grin> Using the other example from Open Office. The code using OLEVariant as a simple object; classSize = .objCoreReflection~forName("com.sun.star.awt.Size") param = .OLEVariant~new( "VT_DISPATCH,VT_BYREF", .nil, "IN,OUT" ) ret = classSize~createObject( param ) arry = classSize~getOutParameters if arry <>.nil then do objSize = arry[1] objSize~Width = 5000 objSize~Height = 1000 objTextFrame~setSize( objSize ) end The same code using OLEVariant as it is now: classSize = .objCoreReflection~forName("com.sun.star.awt.Size") size = .OLEVariant~new( "VT_DISPATCH,VT_BYREF", .nil, "IN,OUT" ) ret = classSize~createObject( size ) if ret == 0 then do size~Width = 4000 size~Height = 1000 objTextFrame~setSize( size~varValue ) end These examples show how the OLEVariant object currently works. Rony and I have both been using this and it seems to work well. I'm interested in comments, suggestions. If it meets with approval, I'd like to get this into the next release. -- Mark Miesfeld mie...@ac... |