Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing and returning arrays
Message
De
15/03/2002 16:43:55
 
 
À
15/03/2002 15:18:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00633588
Message ID:
00633627
Vues:
17
>Is there any way to pass an array from a program to a function, then have the function to update the array and pass it back to the original calling program? I've tried several things and I'm close but no cigar! Below is an example of my attempt to do this. Can someone steer me in the right direction?
>
>*----------------------------------------------------
>PROCEDURE Test1
>*----------------------------------------------------
>LOCAL laArray1, laArray2
>
>DIMENSION laArray1[1,5]
>DIMENSION laArray2[1,5]
>
>laArray1[1,1] = 'A'
>laArray1[1,2] = 'B'
>laArray1[1,3] = 'C'
>laArray1[1,4] = 'D'
>laArray1[1,5] = 'E'
*-- does this meet your requirements?
Test2(@laArray1)
acopy(laArray1,laArray2) && instead of assigning !!!
>laArray2 = Test2(@laArray1)

>
>SUSPEND
>
>RETURN
>
>*----------------------------------------------------
>FUNCTION Test2
>*----------------------------------------------------
>PARAMETERS taArray
>
>DIMENSION laArray3[1,5]
>
>laArray3[1,1] = taArray[1,1] + 'A'
>laArray3[1,2] = taArray[1,2] + 'B'
>laArray3[1,3] = taArray[1,3] + 'C'
>laArray3[1,4] = taArray[1,4] + 'D'
>laArray3[1,5] = taArray[1,5] + 'E'
>
>SUSPEND
>
>RETURN laArray3
>*----------------------------------------------------
>
>In the FUNCTION Test2 I do a suspend and the data in laArray is what I expected. But when I get back to the PROCEDURE Test1 all the elements of laArray2 are filled with 'AA' which is what is in the first element of the laArray3 array.
ramil
~~ learning to stand still
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform