01-06-2011 02:18 PM
I need to read in a short array of strings from a file. I don't want to add more files and wondered if there was an easy way to read an array of strings from an ini file. Since it will only be a dozen strings at most I suppose I could do it brute force:
[STRING ARRAY]
1= "string 1"
...
2="string 12"
Is there a mo betta way?
Thaniks,
jvh
Solved! Go to Solution.
01-06-2011 02:25 PM
@jvh75021 wrote:
I need to read in a short array of strings from a file. I don't want to add more files and wondered if there was an easy way to read an array of strings from an ini file. Since it will only be a dozen strings at most I suppose I could do it brute force:
[STRING ARRAY]
1= "string 1"
...
2="string 12"
Is there a mo betta way?
Thaniks,
jvh
My brute force abproah is not that much different.
[Array_Name_Section]
Num_Items = 3
Array_Name_Item_0 =
...
I sued this approach in that method in my adaptive save restore Nugget as shown in this image below.
Have fun,
Ben
01-06-2011 02:49 PM
I use the OpenG variant config. I never really cared how they store it, but I think it was comma separated.
Felix
01-06-2011 02:58 PM - edited 01-06-2011 03:02 PM
I simply put the entire string array into one key, comma delimted:
StringArray = xxxx,yyyy,zzzz
When I read the key, I add a return to it and treat it as a spreadsheet string.
Edit:
It's probably a good idea to put the strings in quotes, in case you have commas in your strings.
01-06-2011 04:29 PM
I've just recently discovered the OpenG VIs for use with config files.
Here I used their "Write Section Cluster" VI to create a config file which showed me what syntax I needed for editing my config files that will work with their Read VIs:
Of course, the clusters are typedef'd, so all the elements inside this cluster constant have names. Those names are used to automatically create the key names in the config file. You can instantly create a very complex config file by simply connecting up almost any cluster you want to this Write VI (not sure what the limits are, though).
So, the simple, corresponding Read example VI is:
I've used both of these chunks of code in my current project, and I'm very impressed with how much easier it is to initialize huge amounts of arbitrarily complex data. On a previous project, the "Init from Config File" VI spanned about 4 monitor widths to get all the data elements lined up and connected to all the "Read Key" VIs. Now it can look like the code above every time. Just change the cluster typedef.
- Brad
01-06-2011 04:44 PM
Brad, this palette is even more powerful.
Consider, you need to change one of your clusters, e.g. add a new measurement paramter. Just change the type-def and you are done! No need to modify your read config and your write config code, it's automagically adapted. Also using default values in the type-def will set these parameters to reasonable values when you load an old-format config file.
This really saves your day when you need to react on a customers feature wishes. 1/3 of places to change your code -> 1/3 less bugs introduced!
Felix
01-06-2011 05:05 PM
Did a function search for openG but found nothing. Where is it located?
thanx,
jvh
01-06-2011 05:08 PM - edited 01-06-2011 05:08 PM
@billko wrote:
I simply put the entire string array into one key, comma delimted:
StringArray = xxxx,yyyy,zzzz
When I read the key, I add a return to it and treat it as a spreadsheet string.
Edit:
It's probably a good idea to put the strings in quotes, in case you have commas in your strings.
This works and suits my needs quickly.
Thanks to everyone for posting. When I get caught up I will look into openG. Can openG be used with a file that already has the typical sections and keys?
Ben, like your idea too.
01-06-2011
05:10 PM
- last edited on
04-17-2025
04:35 PM
by
Content Cleaner
On NI:
https://www.ni.com/de/support/downloads/tools-network/download.openg-libraries-for-labview.html
or:
http://wiki.openg.org/Main_Page
And the very fast way -> download VIPM (Community is free), you need it to install them anyhow:
Felix
01-07-2011 07:07 AM
@f. Schubert wrote:
...
Also using default values in the type-def will set these parameters ...
Felix
Hi Felix,
No I am not following you around.
Could you clarify the comment about the def of the type def?
Years ago I observed the the defaults defined in constants on the BD where wipped out when the typed was changed and defualt set in the control editor did not propogate to the BD instances.
Form that I have to assume your statement applies to defining the values in the BD.
Do I follow you correctly or did somthing change that I missed?
Your brother in wire, and student in OOP,
Ben