>Is it possible to return an array from a function? I have run a few tests that don't seem to be working unless I am missing something. I have a test function that returns an array with 10 elements each element is numbered 1 through 10. And then each element of the local array that is assigned the value from the test function is assigned the value of 1, or whatever value the first element of the array in the function is, rather than the values 1 through 10.
>
>Any ideas? or Can this be done?
>
>Thanks
Hi Paul,
If you are using 3.0 or 5.0, instead of passing the array, you
should pass a reference to an object that has an array property,
and then change that property as you wish in your function.
Example:
M.MyObject=CREATEOBJECT("MyCustomClass")
DIMENSION MyObject.MyPropertyArray(10)
DO MyFunction WITH MyObject
FOR m.Ncounter=1 TO 10
?MyObject.MyPropertyArray(m.ncounter)
ENDFOR
********************
PROCEDURE MyFunction
********************
LPARAMETER ObjName
LOCAL m.nCounter
FOR m.nCounter=1 TO 10
ObjName.MyPropertyArray(m.ncounter)=m.nCounter
ENDFOR
DEFINE CLASS MyCustomClass AS CUSTOM
DIMENSION myPropertyArray(1)
ENDDEFINE
If you are using any other version like 2.6, all you neeD is pass
array by reference.
Example: DO MyFunction WITH @MyArray
Hope this helps.
Luis Guzman, MCP
"The only glory most of us have to hope for
is the glory of being normal." Katherine Fulleton Gerould