I´m trying to pass a PB array (e.g. long) to a Java method
using EJB client. This method call is executed as call by
value instead of call by reference (that I supposed because
Java does it in that way). Can anybody tell me, how to pass
the PB array as reference? I did not found an answer in the
manuals or in the internet.
I´m using the data type mapping as described in
Application Techniques manual with PB 9.0.1 6533 and JDK
1.4.
Bye. Samanta
*** PB code
long ll_value[1]
ll_value[1] = 3 //set value to 3
iejb_dtm.pblongarray(ll_value) //EJB client method call
st_3.text = string(ll_value[1]) //value is still 3
*** Java code
public void PBLongArray(int[] JavaInt)
{
JavaInt[0] += 1; //increment value by 1
}
On 2 Feb 2004 03:34:19 -0800, Samanta wrote:
>Hi,
>
>I=b4m trying to pass a PB array (e.g. long) to a Java method
>using EJB client. This method call is executed as call by
>value instead of call by reference (that I supposed because
>Java does it in that way). Can anybody tell me, how to pass
>the PB array as reference? I did not found an answer in the
>manuals or in the internet.
>I=b4m using the data type mapping as described in
>Application Techniques manual with PB 9.0.1 6533 and JDK
>1.4.
>
>Bye. Samanta
>
>*** PB code
>
>long ll_value[1]
>ll_value[1] =3d 3 //set value to 3
>iejb_dtm.pblongarray(ll_value) //EJB client method call
>st_3.text =3d string(ll_value[1]) //value is still 3
>
>*** Java code
>
>public void PBLongArray(int[] JavaInt)
>{
> JavaInt[0] +=3d 1; //increment value by 1
>}
Jim O'Neil
Principal Technical Support Engineer
Sybase, Inc.
Concord, MA
thank you for your answer. Of course, it would be esier to
use a single array as return value. But I need a separte
return value as status message.
Have you a source code example for me please? I understand
your description. But how can I write a Java class, which
member variables are known in PB? Or vice versa. Is this
fact described anywhere in the manuals?
Bye. Samanta.
public final class myArray {
int[] val;
}
public void PBLongArray(myArray JavaInt)
{
JavaInt.val[0] += 1; //increment value by 1
}
when PowerBuilder generates the proxies for PBLongArray method, it
will see another Java class reference (myArray) and create proxies for
that as well. Your PB code will look something like:
long ll_value[1]
myArray l_javaArray;
ejbConn.CreateJavaInstance(l_javaArray, "myArray")
l_javaArray.val[1] = 3
iejb_dtm.pblongarray(l_javaArray) //EJB client method call
st_3.text = string(l_javaArray[1]) //value is still 3
This should get you pretty close, but I didn't code this out so again
there may be some slight syntax issues here.
I´m back again. I realized it via holder class/boxed value
with separate get/set functions. That´s why, if I use a
direct write access like "l_javaArray.val = ll_value", PB
often crashes. If I use the get/set functions it works very
well. Also a mix of a set function (to ensure that the java
member variable of first index exists) and direct write
access (with PB long array or any array) results in a crach
of PB (in most cases). But a mix of set function and direct
read access works. ???
I think, this is a very important fact for the manuals,
because Java uses call by reference for arrays (also for
primitive types). PB does not.
Bye. Thanks for all.