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

non operation of COPY TO command 1

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I have the following code

Code:
Select (myfile)
savetime = TTOC(DATETIME())
savefile= 'my_stats_'+(savetime)+'.csv'
Copy To &savefile Csv
Copy To (savefile) Csv

I get an error on both attempts to COPY TO.

Can any one help a puzzled oldtimer?

GenDev
 
Hello,

This is because a file name must contain only valid characters. And based on your code, variable SAVETIME contains forward slashes ("/") and colons (":") which are both NOT allowed in a file name, AFAIK. Try displaying first the content of SAVEFILE first before issuing COPY TO to verify the file name. You may try the ffg. instead:

Code:
savefile = "my_stats_ + ;
[indent]DTOS(DATE) + ;[/indent]
[indent]"_" + ;[/indent]
[indent]STRTRAN(TIME(), ":", "") + ;[/indent]
[indent]".csv"[/indent]


kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Thanks for the heads-up kilroy

Actually, with a cupla edits

savefile = "my_stats_ "+ ;
DTOS(DATE()) + ;
"_" + ;
STRTRAN(TIME(), ":", "") + ;
".csv"

did the trick

GenDev
 
That was easy.

Also see TTOC(Datetime(),1), it'll create a string that'll even sort your files correctly, though you can also add a file date column and sort by that.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top