Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help on Macro Substitution '&'
Message
From
13/08/2013 12:56:06
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
13/08/2013 07:43:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01580299
Message ID:
01580398
Views:
49
>>I am using the following code and it works fine
>>
>>
>>SELECT New_Bills
>>SCAN  && Scans for New_bills up to EOF()
>>*Define Variables
>>	cPsfilepath=ALLTRIM(Myfilepath)
>>	CREATE CURSOR Billcompress (POS C(254)) && Create Temporary Cursor
>>	SELECT Billcompress
>>	APPEND FROM '&cPsFilepath' SDF
>>
>>
>>However when I use APPEND FROM cPsFilepath SDF, it generates error as file not found.
>>
>>My Questions.
>>(1) IS it necessary to have Macro substitue. ?
>>(2) Where and Why Macro Substutes are used ?
>>(3) Does use of Macro substitue decreese the processing speed ?
>>
>>Kinldy Guide
>
>To simply specify a variable for a file name or field name, a name expression (placing the variable in parentheses) is better. Apart from the potential problems with spaces, it will execute faster.
>
>Macro substitution should be avoided if there is another alternative. However, there are some cases where avoiding it would be too complicated, for example when executing a variable SELECT - SQL statement, which might depend on user criteria for example. I also like to use macro substitution when restoring SET options, for example:
>
>
>local lcSetExact
>lcSetExact = set("exact")
>set exact off
>...
>set exact &lcSetExact
>
>
>Here, the macro-substituted line can be avoided, but doing so requires 5 lines:
>
>
>if lcSetExact = "ON"
>    set exact on
>else
>    set exact off
>endif
>
The point of code normalization is to place said five lines in a class or function and get the reuse of the code and the performance saving of not using macro.
Previous
Reply
Map
View

Click here to load this message in the networking platform