LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create ini file for boolean switches

Hello all,

 

I am stuck on something that seems as if it should be very straight forward.  I have a VI that I am using to generate a blob of ones and zeros being passed to a shift register on a prototype board.  I am doing this with 72 boolean switches, which I have placed in a cluster and defined as a typedef.

 

I want to be able to save the state of the cluster of booleans, so I can read it back in to the VI when it starts, to put the board in the last known state before shutdown.

 

Is there a way to save the value and label of every switch in the cluster to a file, then write it back on launch of the VI.  I have been thwarted many times by data type issues etc, using the standard ini file VIs included with Labview 2013.

0 Kudos
Message 1 of 9
(3,721 Views)
  1. right-click the control...data operation..make current value default.
  2. Save the VI
0 Kudos
Message 2 of 9
(3,716 Views)

Hi bump,

 

before I try to answer: havind a cluster containing 72 booleans is a mess. You should rethink your data management/data structure design!

 

Is there a way to save the value and label of every switch in the cluster to a file, then write it back on launch of the VI.

- You could use LabVIEWs XML functions to save the cluster content to file and load it from file…

- You could get the references of all booleans in the cluster and read the label and the value using property nodes. Save the results to a file. When loading the file you need to program a routine setting the values based on the labels of the buttons…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 9
(3,711 Views)

I need to be able to do it from inside an executable, and it needs to write the most recent state before the VI is closed.  I thought there used to be an option to right click, hit create, select invoke node, then choose make current values default.  I can see it on the individual switches, but it isnt available as an option on the cluster of controls.

 

I dont mind setting it up as an .ini file, since eventually I will want to be able to choose from several different configurations at startup.  I am just having real trouble getting those 72 boolean values out in a format that the .ini write VI likes.

 

Sorry in advance for my newbishness.

 

 

0 Kudos
Message 4 of 9
(3,706 Views)

Hi Speedbump,

 

but it isnt available as an option on the cluster of controls.

IT IS! Right click the cluster border

 

I dont mind setting it up as an .ini file

- My first option isn't using the INI file functions…

- The second option could be used to drive the ini file functions as you now have key value pairs (control label and its value)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(3,693 Views)

I have experimented a bit with the XML functions, and I can use the "value" property node to write an XML file with the switch values and names.  I have attached that file.  All I did was use the Write XML file VI, and ran the "value" property node of the cluster into the flatten to XML VI, then to the write XML VI.  When I try to unflatten the data from the attached file and feed it back into the cluster I get errors...I feel like we are getting close.

 

 

0 Kudos
Message 6 of 9
(3,674 Views)

Hi Speedbump,

 

please show your VI (LV2011 preferred or atleast an image) how you save and load the XML file.

 

General rule: when using LabVIEW XML routines you need to use the VERY SAME cluster for saving and loading!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(3,629 Views)

Here is what I ended up with, (at least as far as testing goes).  Thanks for your answers, they helped me get where I needed to go. 

 

 

0 Kudos
Message 8 of 9
(3,603 Views)

The MGI toolkit (available in VI package manager) contains VIs for saving/loading front panel control/indicator state to an INI file.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 9 of 9
(3,590 Views)