Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning value to an array
Message
From
04/04/2000 21:52:10
 
 
To
04/04/2000 21:40:44
Ian Johnston
Computer Software Solutions
Woodland, California, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00355436
Message ID:
00355443
Views:
20
>What is the syntax for returning a value from an array in a function to an array and will it automatically dimension the array it is returning to ?

Arrays are never automatically redimensioned by assigning a value to them.

If you really mean return one element, then the assignment syntax is the same as any other assignment to an array.
LOCAL laArr[1]
laArr[1] = myFunction()

FUNCTION myFunction
LOCAL laArr[1]
laArr[1] = 'Hello'
laArr[2] = 'Goodbye'
RETURN laArr[2]
If, OTOH, you want to return an _array_ (not just an element), the pass the array to the function, like so:
LOCAL laArr[1]
myFunction(@laArr)

FUNCTION myFunction
LPARAMETER taArr
DIMENSION taArr[2]
taArr[1] = 'Hello'
taArr[2] = 'Goodbye'
RETURN
Previous
Reply
Map
View

Click here to load this message in the networking platform