LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate an automatic filename

How can I generate an automatic filename? I want to build the filename from a date- and a time-string. I made a string buffer but the OpenFile command accepts only constant character as filename.
0 Kudos
Message 1 of 3
(3,148 Views)
hi.
no offense pal, but i don't see your pb.
try that please:

char gtc_DataBaseFilePath[260]="";

GetSystemDate (&month, &day, &year);
Fmt (gtc_DataBaseFilePath, "%s<%s\\%i[w2p0]%i[w2p0]%i[w2p0].txt", tc_ProjectPath, year, month, day);

iFile = OpenFile (gtc_DataBaseFilePath, VAL_WRITE_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
WriteFile (iFile, "toto", strlen("toto") );
CloseFile (iFile);

it works fine here.
maybee you have a declaration pb.
0 Kudos
Message 2 of 3
(3,148 Views)
Thanks for your answer,

I had used following code

Fmt (filename,"%s<%s_%s.txt", DateStr () ,TimeStr ());

file= OpenFile (filename, VAL_READ_WRITE, VAL_APPEND, VAL_ASCII);

and get the error "... Invalid argument"

But the problem was that TimeStr used ":" and that is not allowed. With GetSystemTime it was no problem.
0 Kudos
Message 3 of 3
(3,148 Views)