HI...
1) That's example is to undestand de Arrays parameters
2) The array that i am build is a ByRef parameter that i need to recover
- DLL CODE
Public Function exampleFunction( ByRef myArray As Variant)
Dim myArray(7,1) as Variant // 8 rows and 1 col
myArray(0,0) = "string0"
myArray(1,0) = "string1"
myArray(2,0) = "string2"
myArray(3,0) = "string3"
myArray(4,0) = "string4"
myArray(5,0) = "string5"
myArray(6,0) = "string6"
End Function
-- IN Java Code
public static void main(String args[]){
ComFunctions.coInitialize();
Class1 comTest = Class1.create(ClsCtx.LOCALSERVER);
// SafeArray sa -
SafeArray ?????? what is the declaration
Variant param = comTest.exampleFunction( sa ) ;
// And How do recover a Safe Array ??
}
Summary
1- I need to know how to declare a SafeArray to pass to the function
2- How do Recover the safe array with the values that change in the function
THNKS A LOT FOR THIS DUDE.. and the others
1. You just need to instantiate the SafeArray parameter on the Java side and it will be initialized in your exampleFunction:
SafeArray sa = new SafeArray();
comTest.exampleFunction(sa);
2. After this function call you can get the dimensions of the retuned SafeArray parameter using its getDimensions() function:
int dims = sa.getDimensions();
and number of elements in each dimension, using the sa.getCount(int dim) function:
int numberOfElementsInFirstDimension = sa.getCount(0);
int numberOfElementsInSecondDimension = sa.getCount(1);
// and so on
Then, after you got the number of dimensions and number of elements in each dimension, you can easily get an element from the array, using its get(int[] indices) function:
BStr element00 = (BStr)sa.get(new int[] {0, 0});
BStr element60 = (BStr)sa.get(new int[] {6, 0});
Thnks Serge that was very very important note for me, because i resolved my problem and i undestand very good Arrays with jniwrapper..
bye...