MORECHEMISTRY.COM::MORE CHEMISTRY ON THE WEB    
Home Member Area Links Events Publications Promotions
 

LabVIEW programming topics - Using array sets in ini files


Introduction

LabVIEW provides a convenient way to read single data elements from and to write single data elements to ini (config) files. However, for a series of similar data elements, e.g. an array, you should create some method of your own.

The presented method assumes you want to use the following type of data in your ini file:

[section]
key one=value0
key two=value1
..
key last=valuelast

In other words all data elements of an array are stored with a separate unique key.

These data elements may represent numerical values, booleans, or strings as in the following example:

[sample section]
double one=0.000000
double two=0.000000
double three=0.000000
boolean one=FALSE
boolean two=FALSE
boolean three=FALSE

Solution for reading the ini file

The general approach is simply to find the values for all consecutive given keys in a given section and store those value in an array as consecutive elements.

Solution for writing the ini file

The general approach is simply to write the consecutive elements of an array to the consecutive given keys in a given section.

Implementation

This method requires a separate function for each data type. Fortunately LabVIEW offers a method to store all related funtions in a single library and a method to combine similar functions in a polymorphic function.

Sample program

The sample program shows how to read/write values from an array of doubles and an array of Booleans.

Downloads

ini file support - array sets.zip

which includes:

  • ini - open file.vi
  • ini - array set.llb
  • ini - read array set.vi
  • ini - write array set.vi
  • ini - test array set.vi

Remarks

  • The presented VIs were created with LabVIEW 8.5.1.
  • The presented VIs works fine for Booleans, strings (without commas) and the following numerical values: double, single and both signed and unsigned integer.
  • The function for the single format has been derived from the function for the double format. It can be used as an example for other derived formats.
  • When you close an ini file that needs to be updated, don't forget to explicitely wire a TRUE constant to the Close Config Data function.
  • There is no function for Path arrays.
  • At writing a value should be supplied for each named key.

 


Bart Boshuizen, 2011/03/02


© copyright 2000-2014, morechemistry.com
design by Bb.