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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy file error 1

Status
Not open for further replies.

RussA

Programmer
Mar 19, 2003
27
US
I assume I’m getting this error message due to the special characters in the file name, is there a way around this in FP60 / Windows2000 without renaming the file?

Thanks in advance Russ

A record in the table has these values in the two fields.

cDestNam =
C:\FPW60\CDM02\FIRST AND SECOND QUARTER FY'03 & FY'04.XLS

cSourceNam
E:\REVENUE\CDM02\FIRST AND SECOND QUARTER FY'03 & FY'04.XLS

My code
Store alltrim(cDestNam) to hcDestNam
Store alltrim(cSourceNam) to hcsourcenam
Copy file &hcsourcenam to &hcdestnam

I get this error message
Command contains unrecognized phrase/keyword
 
Hi Russ

You have a little problem with the filename/paths containing spaces... when the macro expansion is done it looks to vfp like you've got more than one file parameter.

Change your code to look like this instead:

Code:
Store alltrim(cDestNam) to hcDestNam
Store alltrim(cSourceNam) to hcsourcenam
Copy file (hcsourcenam) to (hcdestnam)

HTH

Regards

Griff
Keep [Smile]ing
 
That wont help because ALLTRIM() only removes leading and trailing spaces, not the embedded spaces.

You also need to enclose the file names in quotes:

Code:
Store CHR(34) + alltrim(cDestNam) + CHR(34) to hcDestNam
Store CHR(34) + alltrim(cSourceNam) + CHR(34) to hcsourcenam
Copy file (hcsourcenam) to (hcdestnam)

Ed

Please let me know if the suggestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
Hi Ed,

Using the brackets is all that's required - the alltrim calls were in Russ's original code to tidy up the probability of having fixed length source fields. On some operating systems (a guess) he could have ended up with a 100 character file extension without it.

If you put the chr(34)s on in the way you suggest, you will get an invalid path name error from VFP

Martin

Regards

Griff
Keep [Smile]ing
 
Hi Griff;

You're right. [blush]
You know, when I woke up this morning I didn't feel stupid.

Ed

Please let me know if the suggestion(s) I provide are helpful to you.
Sometimes you're the windshield... Sometimes you're the bug.
smallbug.gif
 
Thanks Griff that worked well.

Russ
 
Good luck Russ,

No problem Ed, I get confused with the quotes for macros all the time - so I try to avoid them!

Good weekend to all!

Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top