Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get output parameter from invoke #23

Open
Zzirconium opened this issue Feb 8, 2022 · 3 comments
Open

Cannot get output parameter from invoke #23

Zzirconium opened this issue Feb 8, 2022 · 3 comments

Comments

@Zzirconium
Copy link

Zzirconium commented Feb 8, 2022

Hello there,

I cannot manage to get output parameter from a method that has 1 input and 1 output parameter.
Sub PLMCreate((iString, oEditor)

The only way to have something working is to write down the following sequence
Variant editor = new Variant (null, true);
editor.putNothing();
Dispatch.invoke(plmNewService.getDispatch(), "PLMCreate", Dispatch.Method, new Object[] {"somestring", editor}, new int[1]);

The first two lines are there to declare a Variant of VariantDispatch type, then the invoke is called.

Any other combination does not work (inverting parameters as suggested somewhere does not work, removing putNothing does not work because editor is not of the good type - VariantDispatch - , etc.)

after this call, the variable editor is a Variant answering true to isNull() method, in other word it is empty.

This call works great when called directly in VBA.

I have looked at Dispath::invokev source code, and it appears the following line is handling this case (inout parameters)

// to account for inouts, I need to copy the inputs back to

do you know why I do not get a proper return value in editor ?

Many thanks for your help ! This lib is amazing !

@plehal
Copy link

plehal commented Jun 27, 2023

Sad that the question has not been answered after so long. I have various such situations where vba works fine but it is impossible to make jacob work with such inout parameters.

@Zzirconium
Copy link
Author

Thanks @plehal for your support. Once, I downloaded the code and compiled it in debug mode to understand a little bit deeper, but I had to stop at some point. Basically I was stuck at the memory sharing mechanism in JNI call. Pretty sure the solution is not hard to find though, I hope one day I can put the effort back on and find a solution to this.

@EJP286CRSKW
Copy link

Variant editor = new Variant (null, true);

is sufficient. Remove the line

editor.putNothing();

After the call the editor variable should contain the output parameter value. Works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants