LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to implement a config ini reading sequence?

Solved!
Go to solution

Dear Labview community,

 

So far I have implemented a read config using a sequence wired to the error line in such a way that it runs first before everything else.

 

But when a change is made to the config file, the program has to be restarted.

 

Is there a way to implement the config so that it will read before everything else is loaded and at the same time able to be modified without the program needing a restart?

 

Thank you a lot for the contributions!

0 Kudos
Message 1 of 12
(2,768 Views)

@rajiv85 wrote:

So far I have implemented a read config using a sequence wired to the error line in such a way that it runs first before everything else.

 

But when a change is made to the config file, the program has to be restarted.

 

Is there a way to implement the config so that it will read before everything else is loaded and at the same time able to be modified without the program needing a restart?

 

Thank you a lot for the contributions!


You'll probably need more structure in your program.

 

You can reload the settings at any time you want, as long as you program it.

 

For instance, you can have an event structure case that reloads when you press the reload button (or menu). This can also be done with a user event (so you can trigger it with a VI more easily).

 

Further advice would be hard without seeing your code. But usually stepping up to a more sophisticated program structure would be needed.

 

BTW. you might like this library.

0 Kudos
Message 2 of 12
(2,758 Views)

@rajiv85 wrote:

Is there a way to implement the config so that it will read before everything else is loaded and at the same time able to be modified without the program needing a restart?


It's not entirely clear what you mean.

 

If you want to save your settings, you'll have to (on some event) open the file, make your changes, close the file (with save is true).

 

Note that, IIRC, the LV ini file library does not allow to save the file without closing. The linked library will allow that.

0 Kudos
Message 3 of 12
(2,752 Views)

Thank you very much!!!

 

Well attached is the sequence that runs before everything else.

 

Then I have a basic event box with buttons that do a number of operations.

 

The key is to make sure that the config is read before anything else and also that it can be edited without program restart.  

0 Kudos
Message 4 of 12
(2,745 Views)

@      wiebe@CARYA: 

Thank you very much for pointing this out. I noticed that this was the case and after some struggles found out that it had to be closed. 🙂

0 Kudos
Message 5 of 12
(2,739 Views)

@rajiv85 wrote:

@      wiebe@CARYA: 

Thank you very much for pointing this out. I noticed that this was the case and after some struggles found out that it had to be closed. 🙂


A decent ini file library has options to get\set values by reference.

 

IIRc, OpenG has options for that too.

 

By reference, you can simply get an array of references from your front panel (or pane, or cluster). Then each reference is loaded\stored in the ini file by it's label. The label should follow some schema, so the tool can automatically get the section and key name.

 

So, you won't need all the locals anymore.

0 Kudos
Message 6 of 12
(2,723 Views)

By reference, you can simply get an array of references from your front panel (or pane, or cluster). Then each reference is loaded\stored in the ini file by it's label. The label should follow some schema, so the tool can automatically get the section and key name. ''

 

 

>>very interesting, I saw this before but was not clear to me why it was done, now it clicked. Thanks!!!!

0 Kudos
Message 7 of 12
(2,719 Views)
Solution
Accepted by topic author rajiv85

A common solution to your problem is to build the program as a State machine (there's even a template you can open). That way it's easy to rerun "Read ini"-state if you need to.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 12
(2,689 Views)

Thanks a lot. 🙂 I will see how to implement that.

0 Kudos
Message 9 of 12
(2,680 Views)

In most of my application I read a config file at the launch of the program. Then as values are changed, I only update them in local memory - like in a control, a shift register, etc. At the end of the program, I write any changed values to the config file.

 

Maybe you want to re-load the config file for debugging purposes, but it probably does not need to be part of your "finished" code.

0 Kudos
Message 10 of 12
(2,651 Views)