• OCX returning a variable number of variants ?

    From R.Wieser@21:1/5 to All on Fri Jan 7 18:19:50 2022
    Hello all,

    I've written a method which, using VBScript, accepts a variable number of arguments, which is described in the IDL as follows :

    [vararg] HRESULT Put([in] SAFEARRAY(VARIANT) aList);

    But now I want to do the reverse. Call a method with a variable number of variants and have the called method fill them in.

    To be clear about it :

    1) I do /not/ want to return a fixed number of results.

    2) I do /not/ want the method to return an array and than pick my results
    outof that array.

    IOW, I want to be able to use :

    Put(Var1,Var2,Var3, ...) '<-- This already works

    and than :

    Get(Var1,Var2,Var3, ...)

    Question : is what I'm after at all possible ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Fri Jan 7 19:30:57 2022
    But now I want to do the reverse. Call a method with a variable number
    of variants and have the called method fill them in.

    The answer ofcourse popped into my mind mere minutes after having posted the question :

    [vararg] HRESULT Get([in,out] SAFEARRAY(VARIANT)* aList);

    The called method does show the contents of the supplied variants.


    But I've ran into the next problem : when I now use SafeArrayPutElement (to return some values) I do not see it back in the variant(s) I supplied to the method.

    Most likely this is because the contents of the SafeArray are ByRef, and (I think) I'm putting the data into the array ByVal - and thus not into the supplied (ByRef) variant(s).

    Hmmm ... Anyone have an idea for me ?

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sat Jan 8 13:09:50 2022
    On Fri, 7 Jan 2022 18:19:50 +0100, R.Wieser wrote:
    Hello all,

    I've written a method which, using VBScript, accepts a variable number of arguments, which is described in the IDL as follows :

    [vararg] HRESULT Put([in] SAFEARRAY(VARIANT) aList);

    But now I want to do the reverse. Call a method with a variable number of variants and have the called method fill them in.

    To be clear about it :

    1) I do /not/ want to return a fixed number of results.

    2) I do /not/ want the method to return an array and than pick my results outof that array.

    IOW, I want to be able to use :

    Put(Var1,Var2,Var3, ...) '<-- This already works

    and than :

    Get(Var1,Var2,Var3, ...)

    Question : is what I'm after at all possible ?

    Regards,
    Rudy Wieser

    I haven't seen any programming language whose function can actually return multiple values without placing them in some kind of a container or an interface.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sat Jan 8 09:58:00 2022
    JJ,

    I haven't seen any programming language whose function can actually
    return multiple values without placing them in some kind of a container
    or an interface.

    :-) As you might know I mostly write Assembly. In it returning multiple results is as easy as supplying pointers to the respective "variables"
    (read: memory areas) to a function.

    Or, as it is called in several programming languages, providing the argument "by reference" (instead of the more common "by value").

    Ofcourse, there has been a great push to banish "by reference" arguments, as its is much harder to prove that programs which use them do not have un-intended side effects (at least, that is what I've been told by someone
    who studied for it).


    But as a quick test I just tried this method :

    HRESULT GetTest(out] variant* var1,[out] variant* var2);

    and it works fine.

    IOW, thats the second language you now know which can do it. p :-)

    -- but --

    It turns out I made a simple mistake, making it /look/ as if my OCX didn't
    work : while I provided three different variables I displayed the first one twice followed by the third one. And as I test-stored my result in the
    second variable ... :-|

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From JJ@21:1/5 to R.Wieser on Sun Jan 9 13:33:50 2022
    On Sat, 8 Jan 2022 09:58:00 +0100, R.Wieser wrote:
    But as a quick test I just tried this method :

    HRESULT GetTest(out] variant* var1,[out] variant* var2);

    and it works fine.

    IOW, thats the second language you now know which can do it. p :-)

    Functions' out arguments are just pointers to a buffer for the function to fill. They're not the function's return value. That function's return value
    is the HRESULT. They're all function results. But only one is the function return return value.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Sun Jan 9 09:02:51 2022
    JJ,

    Functions' out arguments are just pointers to a buffer for the function
    to fill.

    Indeed. And that is what I was asking for : "and have the called method
    *fill them in*" (bolding mine).

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)