Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RETURN does arrays!
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00570900
Message ID:
00570969
Views:
19
>>>>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.

See Message #570933.
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform