LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The "write key" configuration file vi use of "trim string" prior to writing the data can modify any string data written.

I tried to use the config VIs to record some front-panel settings for later restoration, one of which could be a single space character (part of a string parsing system).

I soon discovered that whenever I tried to save that single-space value to an INI file, only a null string was saved.

After doing some digging I discovered that buried in the Write Key vi is a worker vi called Config Data Modify that uses Trim String on the string data before it is written to the file and that's what was eating my string character. I don't know whether this is a bug or a feature but there are at least three ways to fix it.

 

1) Assuming you want to leave the library VIs alone, you can pre-process any stings sent to "write key" to replace all spaces with "\20" and then post-process all strings read using "read key" to replace all instances of \20 with spaces.

 

  and if you don't mind modifying the library VIs, either to save/use under a different name or to stick back into the library in a modified state (caution - can cause problems when you move code to another machine with an un-modified library) then...

 

2) You can yank the trim-string out of the Config Data Modify vi and hope that it does not have any undesirable side effects with regards to the other routines that use Config Data Modify (so far I have not found any in my limited testing)

 

or

 

3)  You can modify the string pre-processing vi, Remove Unprintable Chars, to add the space character to the list of characters that get swapped out automatically.

 

Note that both option #1 (as suggested above) and option #3 will produce an INI file data entry that looks like    key="\20Hello\20World\20"   while option #2 produces an entry that looks like   key=" Hello World "

 

The attached PDF contains screenshots of all this.

Message 1 of 2
(3,166 Views)

Hi Warren,

 

there's a 4th option:

Simply set the "write raw string" input of the write key function to TRUE Smiley Wink

This option only appears when a string is wired to that function!

 

Just re-checked:

I think it's a limitation of the config file format. It's text based and (leading) spaces in the value are "overseen" as whitespaces. So your next option would be to use quotes around your string with spaces...

Message Edited by GerdW on 05-02-2009 08:32 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 2
(3,152 Views)