Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to: Push and Pop parameters?
Message
De
18/10/2001 10:42:19
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00570224
Message ID:
00570254
Vues:
21
Yeah, I thought of that too. I was just curious if I was missing something. I believe its common practice to have a function / method remember initial settings, make whatever changes are desired and restore the initial settings.

Passing in a copy of the parameter to the function isn't as clean.

>You can work with a copy of a parameter instead of parameter itself. This way you don't have to restore anything.
>
>>Hi All
>>
>>I need to pass a parameter to a method by reference. The called method may alter the parameter, so I want to push the parameter to a property. The parameter may be a string or an array to begin with. I don't believe the save and restore variables to memo fields / .mem files route would be feasible.
>>
>>The problem is, if an initial parameter is passed as a string and pushed to a property, and the called program changes the passed parameter to an array, it doesn't seem possible to pop the parameters so as to cause the array to become a string again.
>>
>>To demonstrate...
>>
>>Junk.prg
>>lcString = "Testing"
>>?junk1(@lcString)
>>disp memo
>>*Notice that lcString is now an array.
>>return
>>
>>junk1.prg
>>lParameters tuParameter
>>*Push the incoming parameters
>>local luParameter
>>luParameter = tuParameter
>>*Convert the string to an array to do some processing...
>>local array laArray[1,1]
>>laArray[1,1]="Something else"
>>dimension tuParameter[1,1]
>>=acopy(laArray,tuParameter)
>>*Do the processing
>>...
>>*Pop the parameter (so that we get back the original string)
>>tuParameter = luParameter
>>return
>>
>>I've tried releasing tuParameter before storing luParameter to it. Any ideas?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform