>>>>I didn't notice this in the "New....." section or the "Enhancements..." section of the VFP7 documentation, nor does the RETURN Command write-up mention it, so I thought I'd mention it here as it seems quite important to me.
>>>>
>>>>An array can be specified as eExpression of a RETURN command provided that:
>>>>1) the array was passed by reference into the function in the first place;
>>>>2) the array is still in scope when the RETURN executes.
>>>>
>>>>Found this reading "What's New in Visual FoxPro 7.0" from Hentzenwerkes.
>>>
>>>Yes, it does work, but probably not like most folks would like. Try the following:
FUNCTION ArrayTest
>>> LPARAMETER ta_foo
>>>
>>> EXTERNAL ARRAY ta_foo
>>> DIMENSION ta_foo[2]
>>> ta_foo[1] = "A"
>>> ta_foo[2] = "B"
>>> RETURN ta_foo
>>>ENDFUNC
>>>
>>>DIMENSION a_foo[1]
>>>a_foo = NULL
>>>a_foo = ArrayTest(@a_foo)
>>>DISPLAY MEMORY LIKE a_foo
You'll see that the array is re-dimensioned but the values in both elements are the same. I also tried this with numbers.
>>
>>It only works when the array is a property of an object. The RETURN in this case is retuning the first element.
>
>I guess that the array being re-dimension is caused by passing by reference. Funny thing is that I haven't seen anything in the docs about this. The enhancement section doesn't even include RETURN. Guess I'll have to play with an object and see what's up there. Your explanation, does make sense, BTW.
Two minor changes to the sample program will property change the array:
DIMENSION a_foo[1]
a_foo = NULL
= ArrayTest(@a_foo)
DISPLAY MEMORY LIKE a_foo
RETURN
FUNCTION ArrayTest
LPARAMETER ta_foo
EXTERNAL ARRAY ta_foo
DIMENSION ta_foo[2]
ta_foo[1] = "A"
ta_foo[2] = "B"
RETURN @ta_foo
ENDFUNC
This is not obvious from the docs, but I believe this is "as designed".
"Problems cannot be solved at the same level of awareness that created them." - Albert Einstein
Bruce Allen
NTX Data