No,
you need to know what cFile is to know the put-together names "File"+cFile and "isBMC"+cFile. Those are the names of the variables addressed. Substitution means replacing, simply as the natural english word meaning. cFile is replaced into the source code and that's recompiled. Every time the line is executed. So this is dynamic. It will depend on the runtime value of cFile. You only use macro substitution, if there will be a variation at runtime, otherwise you could simply use static names you already know at design time, when programming. Many different variables starting their names with "File" and "isBMC" can be addressed by this same code, just changing the value of cFile. So, this are not just two variable names, depending on how cFile changes in an iteration, different calls to this function etc, you can have 4,6,10,100,1000 variables. Whatever cFile changes to. Within a single execution during which cFile is having one value, you can use and only use File&cFile to address this variable and isBMC&cFile for the other, but if cFile changes, these expressions address other variables.
It is all explained already. Are you only theoretically working on this, reading/reviewing source code, or do you have Foxpro at hand? Then I suggest you execute this exercise to understand it.
Macro substitution is universally applicable to any part of the code, commands, as I showed already, another example:
Code:
lcOperator = "="
? 1 &lcOperator 1
lcOperator = ">"
? 1 &lcOperator 1
lcOperator = "<"
? 1 &lcOperator 1
What's really executed is
But since in code cOperator wouldn't be set statically as here, but may come from data or user input, you cannot predict and precompile what will execute later.
If your task is to port this into another language, don't try to port this 1:1, get your head around the overall functionality of the code and program that in whatever other programming language as you'd do it there, you can't redo macro substitution in C# or PHP or Python or Javascript. The nearest you get is with Javascripts and PHPs eval(), which couldn't cover the substitution of the operator, eval is limited to evaluating expressions, which may cover variable names, too, but what language would allow you to dynamically at runtime specify names? By the way Foxpro also has eval, but that won't help you here, too, because no other language would allow declaring variables with names only known at runtime. As I said in the other thread, it might be good to use an array instead, for such situations. in PHP you could use cFile as the name of an array element, as PHP as associative arrays like $myarr['Firstname'], $myarrr['Lastname'] instead of just being able to address array elements with a numeric index $myArr[0], $myarr[1].
Mainly you need to find out how cFile is set and how it varies, which values can occur there. If it's a limited amount of values you know the limited few variable names resulting, if it's random or dynmically changing with endless variations, like SYS(2015) will in my sample code, you have a bigger conversion problem. Unless you don't need to convert but only understand. Then please ask detail question, what you didn't yet understand about the mechanism. It's a mere string replacement + recompile.
Bye, Olaf.