LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic name change each month

Solved!
Go to solution

Hi guys, I've been working on a VI wich does a couple of things and one of them is that it writes into a file a certain number of variables, my question is if anyone out there has tried an "automatic file name change"? For example, everytime the month changes the VI will automatically create a new file named after the month and start writing the variables in that file, that way it wont be named the same always...

 

Any ideas? Here's what I have done till now...

 

Thanks!

 

pre

0 Kudos
Message 1 of 6
(2,821 Views)

Store the current month in a shift register.  Whenever you detect the current month is not equal to the month in the shift register, then execute a case structure where you close the current file path (also stored in a shift register) and open a new file path based on the new name.

0 Kudos
Message 2 of 6
(2,816 Views)

Or how about the simpler Format Date/Time String VI (on the timing sub-palette) - I'm fairly sure that it's a standard VI, it will give you days, months, years, depending on the format string you give it, %m will just give you this month number, and use that in the path directly ny building the title onto it.

 

So a format string of "my file for this %m" going into Format Dat/Time, which is then appended to your base path e.g. "c:\my folder for data" using the append path VI.

0 Kudos
Message 3 of 6
(2,790 Views)

You may also want to consider using a more flexible way to build your string to write to file. I would recommend a state machine and write each element out on its own. The benefit of this type of an approach is that it is much easier to maintain, modify or add elemtns to than a single concatenate string with 25+ inputs. This may sound like an overly complex way to do something simple but it makes life easier whenever you need to make changes.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 6
(2,783 Views)
Solution
Accepted by topic author magb321

Hey Magb..

 

I suggest you check out this example

It teaches you how to programmatically change a file path according to the date the data was acquired; it also uses a state machine to do so.

That way you will only have one file per month even if your VI runs with no stop for 5 months in a row...

You would have to modify it to acquire your data and to store it in the path that you want because this one stores it in "My Documents"

 

Good luck with your application

0 Kudos
Message 5 of 6
(2,771 Views)

Thank you Marisol! Your post was really helpful, and all of the others too of course!! I thank you all.

0 Kudos
Message 6 of 6
(2,733 Views)