Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Found the value of the variable in include file
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00491334
Message ID:
00491793
Vues:
8
>First off you are calling something a variable that is not a variable. What you are dealing with are called constants. When any code is "compiled" what happens is the code is transformed from the commands and syntax that we use to create it, to a format that is readable by, in our case, the VFP runtime libraries, since they translate the complied code into machine code. However constants work the same wether the code is compiled to machine code (VB & VC)or, as in our case, some other type of proprietary code.
>
>Constants are evaluated at compile time. Variables are evaluated at runtime. Here is an example of what this means.
>
>Constant Example
>****
>#DEFINE TWO 2
>#DEFINE THREE 3
>?TWO+THREE
>****
>
>Value Example
>****
>?2+3
>****
>
>In this case, when the "Constant Example" program is compiled the resulting compiled code will look exactly the same as the compiled version of the "Value Example". You see constants are replaced, at compile time, with thier assigned values, just like if you would have just used the values instead of the constants. This is why you cannot store the name of the constant in a variable and use it at runtime because the compiled code has no idea want the name of the constant means beacause all those constant names are lost when you compile.
>
>One issue that can occur if a programmer doesn't understand this is she might change a constant value in an include file but that new value will not be reflected in her code because she did not re-compile.

Thanks, Rip. This is I finally understood by myself :) IOW, I have to use explicit name of the constant and can not access it by name. Therefore I changed my GetDesc routine to use constants by name. Anyway, it slows down the grid, so I decided not to expand the code to its description for now.
>
>
>>Hi everybody,
>>
>>I have several variables defined in include file, for instance:
>>
>>#DEFINE APN_NOTDO ' '
>>#DEFINE APNMS_NOTDO "APN calculation not performed"
>>
>>#DEFINE PARSE_NOTDO ' '
>>#DEFINE PARSEMS_NOTDO "Parsing Mapref not performed"
>>
>>#DEFINE MAPREF_NOTDO ' '
>>#DEFINE MAPREFMS_NOTDO "Changing Mapref not performed"
>>
>>#DEFINE APN_COMPL 'C'
>>#DEFINE APNMS_COMPL "Completed APN calculation successfully"
>>
>>#DEFINE PARSE_COMPL 'C'
>>#DEFINE PARSEMS_COMPL "Completed Parsing Mapref successfully"
>>
>>Now I want to retrieve the values of these variables, but I want to use variable name, e.g.
>>tcVarName could be "APN","PARSE" or "MAPREF" and I want to retrieve APN_COMPL value. I tried different combinations and nothing worked.
>>
>>Is it possible at all? Could you please help me here?
>>
>>Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform