Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP Command Syntax Mystery

Status
Not open for further replies.

JRB-Bldr

Programmer
May 17, 2001
3,281
0
0
US
I have a developer creating a VFP7 program for me. We both have VFP 7 on our systems.

Within the program he needs to copy a file to another location and is using the COPY FILE command.

On his machine he is using:
mFromFile = "F:\ABC\Dir_1\ThisFile.txt"
mToFile = "F:\ABC\Dir_2\ThisFile.txt"
COPY FILE &mFromFile TO &mToFile

Everything works well for him.
But on my machine I get an error:
Illegal Syntax/Phrase

However if we change the last line to:
COPY FILE (mFromFile) TO (mToFile)

Everything works well on both systems.

I have encountered similar issues with other commands on my system where use of the &variable generated an error and use of (variable) did not. Also this problem seems to be specific to certain VFP commands.

Example:
SET PATH TO &mPath && Does NOT work
REPLACE &mFld WITH "123" && Does work

Why the difference???

Your suggestions and advice is greatly appreciated.

Thanks,
JRB-Bldr
 
THis does on solve your mystery, but it has been my experience that the &whatever sometimes fails when there are blank spaces in the path or filename.

Enclosing the variable in () as you found out works.


Jim Osieczonek
Delta Business Group, LLC
 
I too faced the same problem several times. But most of the times it was solved when I used "&whatever".

Puru
 
The difference between the macro operator & and the name expression () is subtle. In general, a macro expression replaces a string whereas a name expression replaces a name. Fox though is quite sloppy in its syntax and there are many places where it's equally happy to have a name or a string - for example USE MyTable and USE "MyTable".

Name expressions are supposed to be faster so I always try them first.

Geoff Franklin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top