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:
00571301
Views:
26
>George,
>
>>>>>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.
>
>THAT was the point of my writing this thread. And equally importantly is that if there are "quirks" to the way it processes 'depending on' then these need to be spelled out too.
>
Jim,

Well, I don't think that this is any sort of "quirk". My post was inaccurate because of one thing: I'd didn't RTFM! After reading it (and giving it some thought), I understood exactly why this did what it did. First, and most importantly, the code I posted was not based on the intent of the enhancement. Second the behavior can probably be replicated in 6.0. So I don't see it as any sort of quirk.
George

Ubi caritas et amor, deus ibi est
Previous
Reply
Map
View

Click here to load this message in the networking platform