ni.com checkout is currently experiencing issues.
Support teams are actively working on the resolution.
ni.com checkout is currently experiencing issues.
Support teams are actively working on the resolution.
03-26-2024 04:45 PM
Hello!
I have a .ini file and would like to convert it to cluster and use the data within LabVIEW
The tables/arrays are dynamic and can be larger or smaller, I tested with several ways and could not solve the situation to meet all cases
I've attached the .ini file and the Vi I'm building
03-26-2024 05:13 PM
Please do a "save for previous" (LabVIEW 2020 or below and attach your VI again.
Clusters are fixed size and defined at compile time. Why does it need to be a cluster?
Maybe you can define a cluster will all possible fields, then only use some of them?
03-26-2024 05:18 PM
Oh, I asked if it was a cluster because of how easy it is to work with
But if there's another way I don't see a problem
03-26-2024 05:42 PM
So what exactly do you need at the end?
I was confused by your convoluted code, here's maybe a simpler way to read the data as 2D array for further processing.
How is this data used later and how does your array diagram constant fit into the equation?
One possibility would be to build a MAP (key/value pairs)
03-26-2024 08:14 PM
It looks like whoever wrote the INI file is using MGI's Read Write Anything. You can use their library to convert the ini file to a cluster. You will need to define the cluster that you want from the INI file; it is supposed to be the same cluster that was used to write the file. I do not remember how it handles missing fields, errors, etc.
03-27-2024 06:43 AM
Hello
you can't create a cluster from a text file. Or you need scripting.
But you can manually create a cluster, and the manually set every value.
You can read INI file with Labview VIs "Configuration":
And this example :
03-27-2024 07:36 AM - edited 03-27-2024 07:44 AM
This is a job for LabVIEW Scripting. It absolutely is possible to get LabVIEW to (a) look at a data structure, (b) analyze and figure out what types it contains, (c) use "other means" to create meaningful "Cluster names" for the putative Cluster Elements, and then (d) create the Cluster. I did this in one of my first major LabVIEW projects, taking an Excel WorkSheet whose column headings became the "name" of a Cluster element and whose type was determined by analyzing the contents of the data contained in that column (from a Master WorkSheet that had "sample data" that could be analyzed to determine if it was a Dbl, I32, Boolean, String, or (other things I don't remember now). I made a Cluster (>100 elements!) that I could read an entire WorkSheet row into, and then when I needed, say, "Elevation", I would Unbundle by Name and get the Dbl value it contained.
Go to the Web and search for LabVIEW Scripting Tutorial.
Bob Schor
03-27-2024 07:52 AM
@mcduff wrote:
It looks like whoever wrote the INI file is using MGI's Read Write Anything. You can use their library to convert the ini file to a cluster. You will need to define the cluster that you want from the INI file; it is supposed to be the same cluster that was used to write the file. I do not remember how it handles missing fields, errors, etc.
I second the motion for MGI Read Write Anything which I've been using for almost 20 years now.
Fields that are missing in the .INI file will either be assigned the datatype's default value (0, False, empty string, etc) OR you can optionally provide a cluster of default values as an input wire.
Remember to make your cluster into a typedef! (Right-click cluster boundary, "Make Type Def", then save.) Beware if manually editing -- it does not like extra whitespace around the '=' assignment.
-Kevin P
03-27-2024 07:58 AM - edited 03-27-2024 08:09 AM
Really, the .ini file was created using MGI Write Anything
I was trying to convert the ini data using that (MGI Read Anything), but i couldn't
Updated files, with the creation of typedef
03-27-2024 09:55 AM
You can use my Ini-handler