07-04-2018 05:49 PM
Hello, I creating an vi that needs to save the number wrote by the operator, the numerical must change to it and be saved.
I've been reading about this and I found out it cant be done while its running.. so I hope there's a way for me to do it.
For example right now the num starts with a constant, (outside of the while loop), then it can be changed by the operator while running of course, but this number wont be saved in the vi. how can I achieved that? how to make a new default?
Solved! Go to Solution.
07-04-2018 08:27 PM
The conventional method to save a "constant of the Program" when the Program is not running is -- to save it "outside the Program", i.e. write it to a file. A common name for such files that store "evolving Constants, or Configuration Information" is a Configuration File. One form of such things are often called ".ini" files and have a set format. There is a sub-Palette, called "Config File VIs" on the File I/O Palette. There are also examples included with LabVIEW (look in the File I/O section under "Configuration (INI)".
Bob Schor
07-05-2018 06:51 AM
Technically, you can do that while your program is running (VI Server), but the VI can't be running. In will be unconventional, and it will never work in the executable (that you eventually should\want to make).
Bob's solution is the way to go.
07-05-2018 09:58 AM - edited 07-05-2018 10:01 AM
Sorry for the delay, I´ll try it your way, do you know how can I make a new ini so I wont use the one in the example?
I have this atm:
07-05-2018 10:16 AM
Typically, you'd want to automate the read. For instance make a VI that get's labels from either the front panel or a cluster, and make it use those labels to fill the values. If you look at any decent ini (, JSON, XML) file reader it will have functions to ease that task. NI's ini file lib doesn't have that, draw your own conclusion.
07-05-2018 10:50 AM - edited 07-05-2018 11:01 AM
So a INI file can be created from a notepad saved as .ini, I now having troubles since it isnt finding it, in the direction I put it, and I also added to the project
07-05-2018 12:36 PM
Thank Bob, it works now, it is in the Labview Data Location, is there a way to change that? when I tried it, it marks another error. I wonder if it will be a problem when I make it an exe.
I´ll attach my previous error: it used to say NI_LVConfig.lvlib:Load.vi and NI_LVConfig.lvlib:Open Config Data.vi
atm no problem yet
07-05-2018 02:42 PM
The Forum works best when we get entire VIs (not pictures of parts of the VI). Among other things, we can then see what version of LabVIEW you are using (so we don't send you a LabVIEW 2018 example while you are running LabVIEW 2014, for example). So I'll assume you are using LabVIEW 2018 (since that's what's installed here).
Oh, never mind. I decided to first "follow my own advice" and look at the LabVIEW Example. So I can answer your question about why it is in the LabVIEW Data Location, and "is there a way to change that?". It looks very similar to your "ina kinda fix":
Look at the Build Path function. I assume you know that this builds a Path by combining a "Base Path" (usually a Drive or Folder) and a "Name" (usually a Filename+extension). The name part is easy. What's that function going into the Base Path? [You could look it up, or right-click and choose Help on the function in your code].
So the next question is, where do you want the file to be saved? If it is an "absolute path" (starting with the Drive letter and including the entire Folder Tree, e.g. "E:\Forum\My Test Folder"), just write that path down. There are other "named" Paths that might be more relevant -- look in the File Constants sub-Palette of File I/O.
Bob Schor
07-05-2018 03:33 PM - edited 07-05-2018 03:46 PM
07-06-2018 01:37 AM - edited 07-06-2018 01:39 AM
Hi Franco,
it´s a project with global variables so I didnt think it would work if attached
I don't see global variables in your images, but I see a lot of local variables and shared variables.
And I see race conditions because of overuse of local variables!
Please read the LabVIEW help on the topic "DATAFLOW". Then use wires instead of locals.
And learn about patterns like state machines or producer-consumer-schemes - this will help you in implementing better software…
Are you really aborting VIs? (I don't know what they are doing, but most often one should cleanup before exiting instead of a simple "abort"…)