LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pro-grammatically create a path when using Write Waveforms to a File.vi

Solved!
Go to solution

How do you create a unique file name when using  Write Waveforms to a file.vi that is in a loop ?  I have that VI in a for next loop and want my file name to be unique to each iteration of the loop.  For example, the 1st iteration of the file might be c:\testing\filename1.dat  then next c:\testing\filename2.dat ..then c:\testing\filename3.dat ..etc..  How do you concatenate the file name w the loop iteration to come up w a filename that is unique w each loop?

 

thxs

0 Kudos
Message 1 of 5
(2,975 Views)
Solution
Accepted by topic author Clint1000

Use Format Into String to combine the base filename with the iteration number to create a new file name.  So your format string could be filename%d.dat

 

Then use Build Path to combine the file name with your base path for the directory structure.

Message 2 of 5
(2,974 Views)

Perfect..thank-you.

0 Kudos
Message 3 of 5
(2,954 Views)

A very tiny addition:

 

You might want to consider a number format specifier like "%03d".  This would pad with 0's and make all numbers 3 digits wide, which is handy when you want to sort by filename when navigating into the folder.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 5
(2,916 Views)

@Kevin_Price wrote:

A very tiny addition:

 

You might want to consider a number format specifier like "%03d".  This would pad with 0's and make all numbers 3 digits wide, which is handy when you want to sort by filename when navigating into the folder.

 

 

-Kevin P


Or maybe just use the built-in function that AQ wrote, located in the Advanced File Function Palette:

 

Snip.png

 

mcduff

Message 5 of 5
(2,909 Views)