Example Code

Save Controls to Config File (*.INI)

Code and Documents

Attachment

Overview

A collection of VIs for saving the values of a number of controls to an INI file.

Description

These VIs make the task of storing/recalling the values of front panel controls easier. The load and save VIs take the file name and section name of the INI file, and an array of references to the required controls. Key names are calculated from the referenced control names.

The functions can handle digital, string, boolean, visa resource and path controls including simple clusters.

The advantage of using a config file is that it can be edited using any standard text editor (such as Windows notepad). Also controls can be added/removed/renamed quite easily with most of the data in the config file remaining valid. The ability to define the section name in the config file allows multiple groups of settings to be stored within a single file.

The following VIs are included:

File - Load Controls from INI.vi

File - Save Controls to INI.vi

Play - Config File.vi

File - Valid Key Name.vi

General - Generate Error if True.vi

General - String to Boolean.vi

File - Create Directory Path.vi

Config File.png

[Section]

ValueFloating = 3.141000

ValueBoolean = "TRUE"

ValueInteger = 63.000000

FilePath = "d:temp.txt"

String1 = "Hello"

DigitalMeter.Type = "34401A"

DigitalMeter.VISAresourcename = "GPIB0::17"

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Eric_BOB
Member
Member
on

Hello Thanks for your example. But do you know those Vi's, you do similar things without need to specify reference to controls.They are disponible through Openg and MGI Packages, installable with VIPM.( OpenG Read Panel from Ini and Openg Write Panel to Ini)

Read Write front Panel Controls Values.JPG

antony.g
Member
Member
on

Thanks for the information, I will take a look at the MGI packages.

In a lot of cases I only need to save/load certain controls values, especially if I have multiple sections on my front panels or have used tabs, so it is useful to only reference the controls required.

mohammadmot
Member
Member
on

Hi every body

How can i read all values from ini file and save in variable (in my behinde code), without load values into front controls?

extra comment:

In my case i need to have values from 4 section inside my code as variable, section0 for channel0, ..., section3 for channel3

Contributors