Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Macro Substition Idea
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01098713
Message ID:
01098732
Vues:
15
Macro are a good idea, slows the execution of the code. When a macro is encountered, value of the variable is substituted, and the entire line is compiled before it is executed. The Evaluate() function performs faster then Macros, because the expression is the only thing being evaluated at runtime.
SELECT 0
USE BSpotDt

cAlias = "BSpotDt"
dAirDate1 = eval(&cAlias+".AirDate")

? dAirDate1


>I have often heard that macro substition is not a good idea.
>
>Instead of using:
>
><pre>
>SELECT 0
>USE BSpotDt
>
>cAlias = "BSpotDt"
>dAirDate1 = &cAlias..AirDate
>
>? dAirDate1
>
>
>Why not do:
>
>
>
>#DEFINE FLD_AIRDATE BSpotDt.AirDate
>
>SELECT 0
>USE d:\projects\testdata\smts\bspotdt
>
>dAirDate2 = FLD_AIRDATE
>
>? dAirDate2
>
>
>Then the expression is compiled in, versus evaulated at runtime. If/when your structure
>changed, it would be no more work to change it then with the macro version. Maybe even
>less work because there is only one play you really have to change - the .h file.
>
>Any thoughts?
Greg Reichert
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform