Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array property as a referenced parameter to a function
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00047926
Message ID:
00047970
Vues:
36
>>*pay attention to the macro syntax
>>FOR i = 1 TO ALEN(loObject.&lcArrayName,1)
>>   lcMess=lcMess+' '+loObject.&lcArrayName.[i]
>>ENDFOR
>
>That's clever. In fact, if you have a character string that serves to resolve the object reference to the array, then you can play several variations on the same theme.
>
>Lets assume that you have a property array called oMyObject.aMyArray[10]. Put a character string that references the array into a memory variable: cMyArrayRef= "oMyObject.aMyArray"
>
>Now you can pass cMyArrayRef to a function and have the function do either of the following:
>
>1. Extract the entire contents of the array into an internal, temporary array by saying:
>ACOPY(&cMyArrayRef, aSomeNewArray) -- this will work fast because the macro only needs be evaluated once
>
>2. Use the EVAL() function to access the Nth element of oMyObject.aMyArray by saying:
>cThisElement=cMyArrayRef + "(N)"
>Now you can change the value of N as often as you like and resolve the value of the Nth element by simply asking for Eval(cThisElement)
>
>You might think that you can use the Eval function to create an object reference explicitly for the array:
>oMyArrayRef=Eval(cMyArrayRef), and proceed by enumerating oMyArrayRef(1), oMyArrayRef(2), etc.
>...but this won't work. Instead, Eval(cMyArrayRef) returns the value of the first element in the array.
>
>The big suck is that VFP won't let you simply pass the property array by reference.

Yes, but in the initial message Jorge ask for a way to reference an
array without copy it...

:)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform