Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Macro substitution
Message
 
To
08/04/1998 17:15:19
Raul Davila
Davila Programming Services
Toa Alta, Puerto Rico
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00090513
Message ID:
00090603
Views:
26
Raul,

You could increase your performance quite a bit by using EVAL() instead of macro substitution.

Try this:

? EVAL(get_var_name_part1() + get_var_name_part2())


>>Raul,
>>
>>I don't think you understand what the period delimiter does. Basically, it tells the interpeter that it should append whatever is after the . to the end of the value of the variable that you substituted.
>>
>>var_value=5
>>x='var'
>>? &x._value
>>
>>The ? line is the same as doing:
>>?var_value
>>
>>The interpreter just changes the x to var, then appends the _value to it.
>>
>
>Hi:
>
> Your example gave me another idea that helped me achieve half of what I wanted.
> The way you put it I use it a lot, the problem was when the appended part
> of the variable name is not known beforehand.
>
>var_value = 5
>var_name_part1 = 'var'
>var_name_part2 = '_value'
>
>I was tring:
> ?&var_name_part1.var_name_part2 hoping VFP would append it.
>
>It came out to be:
> ?&var_name_part1.&var_name_part2
>
>Now let's say the parts of the variable name come from functions:
>
>var_value = 5
>
>function get_var_name_part1()
> return 'var'
>
>function get_var_name_part1()
> return '_value'
>
>I wanted something like:
> ? &get_var_name_part1() + get_var_name_part2()
>
>But it doesn't work. I just wanted to cut down the amount of instructions in a series of FOR and DO WHILE loops. The functions are needed because I can't know beforehand the actual name of the variable.
>
>But I'll leave them as they are.
>var_name = get_var_name_part1() + get_var_name_part2()
> ? &var_name
>
>Thanks.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform