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!

Unable to copy file programaticly.

Status
Not open for further replies.

sfr10000

Programmer
May 22, 2006
12
0
0
DO
I need to copy a file programaticly. Seems simple,
"Copy file A to B". This works fine from the command prompt. However I cant find a way to say A and B are field
names containing the desired file names. I tried useing
"&B" for the destination file, I get a new file named "&B".
 
Since you're taking the file names from a table try this:

Code:
lcFile1 = ALLTRIM(table1.field1)
lcFile2 = ALLTRIM(table2.field2)
COPY FILE (lcFile1) TO (lcFile2)

Steve
 
That works great, thanks for helping with such a basic question.
 
Other way out is to create a macro holding all command then execute it with &.
But SGLong, I like your way better ;))
 
In most cases it is best to have the habit of using name expressions (the parentheses) or the EVALUATE() function rather than macro substitution wherever possible, if only because macrosubstitution is several times slower than the other methods. In the example above, it wouldn't be an issue, but if it were in a loop or nested loops doing thousands or millions of iterations then you might notice the code running slower.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top