LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make a new default of numerical while/after running

Solved!
Go to solution

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?

0 Kudos
Message 1 of 11
(2,496 Views)

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

Message 2 of 11
(2,472 Views)

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.

0 Kudos
Message 3 of 11
(2,448 Views)

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:

 

Download All
0 Kudos
Message 4 of 11
(2,434 Views)

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.

0 Kudos
Message 5 of 11
(2,425 Views)

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

Download All
0 Kudos
Message 6 of 11
(2,421 Views)

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

Download All
0 Kudos
Message 7 of 11
(2,408 Views)
Solution
Accepted by topic author FrancoCG

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":

Write Config.png

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

0 Kudos
Message 8 of 11
(2,395 Views)
Sorry, it´s a project with global variables so I didnt think it would work if attached, so I used the pictures.  I´m using labview 2014, but all of what you told have been useful.
I did use the help, but didnt quite understand it until I read your comment, I throught I had to use the little folder, but as I was told by you,  I wrote the path down and it worked. Thank you again.
 
😄
Download All
0 Kudos
Message 9 of 11
(2,389 Views)

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"…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(2,362 Views)