The Configuration VIs found under Functions»Programming»File I/O»Configuration File VIs can be used to write the values of controls and indicators to a config file.These files are organized as a set of sections, specified by section headers, each with its own associated key-value pairs. Follow the steps below to write the values of your Front Panel controls to a config file:
Obtain references to both the config file you would like to write to, or create, and your Front Panel controls.
For the config file reference, use Strip Path and Build Path, in conjunction with the current VI's path.
For the Front Panel controls reference, you can use Property Nodes to get a reference to the Front Panel itself and then to the controls within the Front Panel.2. Create/open your config file using Open Config Data vi. This VI prepares a config file for read/write operations.
For each control on your Front Panel, extract its name and value using a Property Node and convert this information to the proper format.
Before writing the data to file, we must first convert the variant type returned by the Value property to its corresponding data type. Use Get Type Information vi (Functions»Programming»Cluster, Class, & Variant»Variant»Data Type Parsing) to determine the data type and feed the type output into a case structure to conditionally handle each data type present in your Front Panel controls.
Within each case, you can use Variant to Data to convert the Value variant to its corresponding data type. Keep in mind that you will need to fill in cases for all of the data types you wish to store (but not all possible data types). See the Related Links section to learn more about using variants in LabVIEW.
Once you have the control's value in the proper format, use Write Key vi to write the control's value to the Controls section of the config file under the key specified by the Label. Text property. This is the name of the control on your Front Panel.
After completing steps 3 and 4 for each control, close the config file reference using Close Config Data vi. It is also good practice to include some type of error handling to manage any errors encountered during program execution. In this example, we have used Simple Error Handler vi.
Upon reopening your VI, this process can be reused to preload your controls with the values saved to your config file. Substitute Write Key vi with Read Key vi, using the name of the control (key) and appropriate section to obtain the saved value of the control. You can then write this value to the control using a Property Node.Note: There are two shipping examples in the LabVIEW Example Finder called Read Configuration Settings File vi and Write Configuration Settings File vi that can be used to learn more about using the Configuration File VIs. The LabVIEW Example Finder can be found in LabVIEW by selecting Help»Find Examples...
Thank you for your feedback.
You changed your response to Not Helpful
You changed your response to Helpful
Collaborate with other users in our discussion forums
A valid service agreement may be required, and support options vary by country.