Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Local vs Private Parameters
Message
De
16/04/2007 14:12:50
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01216334
Message ID:
01216408
Vues:
19
>>>>It appears that creating a function via
>>>>
FUNCTION myFunc (p1 AS String, p2 AS Int,...etc)
>>>>creates the paramaters as Local variables.
>>>>
>>>>Using the same syntax, is there an option somewhere that would allow them to be created as PRIVATE????
>>>>
>>>>Thanks......Rich
>>>
>>>I thought it would create them as private (guess I was wrong). Using Parameters vs LPARAMETERS statement gives you more control.
>>
>>Yeah, I know that. Unfortunately there are a couple of hundred little modules using this syntax and I was hoping to be able to convert them without having to dig through them all.
>>
>>That being said, maybe it's better to check them all since a couple of the modules might really need the local versions.
>
>Why would you want parameters to be private?
In this case, the parameters are used to build SQL statements which are passed to another object which does the actual data call. Since the parameters are local, I can't use "WHERE field = ?myVar" syntax since myVar is out of scope in the data retrieval object.

Yes I could rewrite the receiving method to accept a parameters object. I could probably do several things differently. It just seemed to me when I posted the message that a global situation making the parameters private would be the simplest way to go and involve the smallest amount of code restructure.

>I guess in most situations you would prefer to have them local, so the default behavior is correct to make the parameters local. In rare cases where you do need them private you should use PARAMETERS approach.

>
>You can also always declare private variables in the function and assign parameters to them. Extra step, of course...

One of the "several things I could do differently"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform