You can pass string data with no problems. try Passing an array and you get
Error 92.909: One or more of the parameters could not be coerced to the desired type. The first parameter with incorrect type is argument 1.
this has been talked about over the years I have seen replies by Mark Miesfield and rony
Also the Out parm doesn't work in that oorexx doesn't report any errors but sets getOutParameters to .nil when there is definitely output to be collected.
call the program from another c# program and it works with both arrays and out parms.
I know the problem is marshalling and unmarshalling but we don't seem to have any control over this - perhaps we should have a tracing facility to see what's going wrong then the ability to match the in/out parts.
I am not a programmer but I can get simple things working
here is the c# program
namespace Widget
{
public class Greeter
{
public void SayHi(string message, out string message2, out string message3) { System.Console.WriteLine("this is written from greeter program ==>" + message + "<==="); message = "new mesage"; message2 = "xxxx nnnnnn"; message3 = "unknown"; System.Console.WriteLine("this is written from greeter program, message is now set to ==>" + message + "<==="); System.Console.WriteLine("this is written from greeter program, message2 is now set to ==>" + message2 + "<==="); System.Console.WriteLine("this is written from greeter program, message3 is now set to ==>" + message3 + "<==="); } } public class Greeter_only_array { public void SayHi(string[] PassArray) { for (int i = 0; i < PassArray.Length; i++) { System.Console.WriteLine("PassArray[" + i + "] =" + PassArray[i]); } PassArray[4] = "this is still index 4 but with a new value"; } }
}
the simple oorexx program
greeter = .OLEObject~New("Widget.Greeter")
message = "hello this is a different"
message2 = "qwerty uiop"
message3 = "notset"
PassArray = .array~new
PassArray[1] = "line 1"
PassArray[2] = "line 2"
PassArray[3] = "line 3"
say "PassArray~items =" PassArray~items
trace i
greeter~SayHi(message, message2, message3)
say "message =" message
say "message2 =" message2
say "message3 =" message3
if greeter~getOutParameters <> .nil then
do
say "result for parm2 =" greeter~getOutParameters~at(1)
say "result for parm3 =" greeter~getOutParameters~at(2)
end
greeter_only_array = .OLEObject~New("Widget.Greeter_only_array")
greeter_only_array~SayHi(PassArray)
std_out
PassArray~items = 3
this is written from greeter program ==>hello this is a different<===
this is written from greeter program, message is now set to ==>new mesage<===
this is written from greeter program, message2 is now set to ==>xxxx nnnnnn<===
this is written from greeter program, message3 is now set to ==>unknown<===
message = hello this is a different
message2 = qwerty uiop
message3 = notset
err_out
11 - greeter~SayHi(message, message2, message3)
>V> GREETER => "an OLEObject"
>V> MESSAGE => "hello this is a different"
>A> "hello this is a different"
>V> MESSAGE2 => "qwerty uiop"
>A> "qwerty uiop"
>V> MESSAGE3 => "notset"
>A> "notset"
>>> "The NIL object"
12 - say "message =" message
>L> "message ="
>V> MESSAGE => "hello this is a different"
>O> " " => "message = hello this is a different"
>>> "message = hello this is a different"
13 - say "message2 =" message2
>L> "message2 ="
>V> MESSAGE2 => "qwerty uiop"
>O> " " => "message2 = qwerty uiop"
>>> "message2 = qwerty uiop"
14 - say "message3 =" message3
>L> "message3 ="
>V> MESSAGE3 => "notset"
>O> " " => "message3 = notset"
>>> "message3 = notset"
15 - if greeter~getOutParameters <> .nil
>V> GREETER => "an OLEObject"
>M> "GETOUTPARAMETERS" => "The NIL object"
>E> .NIL => "The NIL object"
>O> "<>" => "0"
>>> "0"
20 - greeter_only_array = .OLEObject~New("Widget.Greeter_only_array")
>E> .OLEOBJECT => "The OLEObject class"
>L> "Widget.Greeter_only_array"
>A> "Widget.Greeter_only_array"
>M> "NEW" => "an OLEObject"
>>> "an OLEObject"
>=> GREETER_ONLY_ARRAY <= "an OLEObject"
21 - greeter_only_array~SayHi(PassArray)
>V> GREETER_ONLY_ARRAY => "an OLEObject"
>V> PASSARRAY => "an Array"
>A> "an Array"
- Compiled method UNKNOWN with scope "OLEObject"
21 - greeter_only_array~SayHi(PassArray)
Error 92 running Q:\std\QApacks\rexx_scripts\oorexx_subs\Test_Widget_greeter.rex line 21: OLE error
Error 92.909: One or more of the parameters could not be coerced to the desired type. The first parameter with incorrect type is argument 1.
Anonymous
Ticket moved from /p/oorexx/bugs/1249/
Can't be converted:
This is not really a bug, so moving it to the feature requests category.