01-06-2006 02:53 PM
01-06-2006 06:08 PM
As far as I know there is no way of excluding quotes and spaces using the inifile instrument unless you decide to modify the instrument itself (which is distributed with source so that can be customized in case of need).
Some years ago I succesfully modified this instrument adding two extra function panels for Ini_Put and Ini_Get functions which (if I remember well: it happened wth rel. 5 or 5.5 of the language ) take a flag as an input for "Has quotes" parameter. You may want do follow this way in case this item is strategic for you.
To modify the instrument, select the inifile instrument in the list of instruments and execute "Attach and edit source" function to see the source code for the instrument.
Despite my trial, I finally decided to abandon these modifications mainly for not having to check and modify each version of the instrument after every patch or new release of CVI. But this is a personal attitude and you may feel this is not a severe handicap with respect to what you gain following the customization way.
01-09-2006 02:13 AM
11-14-2011 09:56 AM
Hi Roberto,
I ran in to this very same issue where I don't want spaces surrounding equal sign. After creating this ini file I am passing it to a dll but this third part dll doesn't work with extra spaces. I looked at ini file spec and there is no set standard for spaces surrounding equal sign.
I looked in to Ini_SetTokens and default value separator is without spaces. "="
So where are these extra spaces coming from when I write to ini file and how to remove them?
I tried following function but it doesn't work.
Ini_SetTokens (handle, '[', ']', "=", ";");
Help says:
This function specifies the tokens used as delimiters in the text representation of the sections headings and tag/value pairs.
If you do not call this function, the default tokens are:
Section Name Start Character | "[" |
Section Name End Character | "]" |
Value Separator | "=" |
Comment Marker | ";" |
11-14-2011 10:51 AM
The item separator is defined in Ini_SetTokens, specifically in this line:
sprintf(iniText->nameValueOutputSeparatorToken, " %s ", iniText->nameValueInputSeparatorToken);
You may want to modifiy this line to put extra spaces away. Remember to either rename the inifile instrument or to keep a copy of the modified source, since some CVI update could modify this instrument without notice.
11-14-2011 11:17 AM
Thanks for your quick response Roberto. It is working as expected.
To me, this looks like like a bug.
Ini_SetTokens function in inifile.c adds this spaces which doesn't make sense since there is valueSeparator argument to this function.
Anyways, I have modified my copy for now.
04-26-2019 03:41 PM
I realize this thread is very old but I just thought I'd post something and hopefully save somebody some headaches.
From my experience working with CVI2015 the inifile.fp function panel always puts spaces on either side of the equals sign and also puts quotation marks around strings. These formats are incompatible with the software whos ini file I'm modifying. But I was able to write some C code that creates a powershell command line to locate and replace strings in a text file. here is how I call it and how the function looks. But to use it you need to have a way of sending commands to powershell from your Labwindows code. Let me know if you need that.
04-27-2019 02:16 AM
It may be worth noting that starting from CVI2012 Ini_SetAddQuotesToStrings function has been added to IniFile instrument: as the help recitates
Specifying 0 or selecting No in the Add Quotes To Strings parameter of this function panel modifies the behavior of the Ini_Text so that Ini_WriteToFile and Ini_WriteGeneric write string values without the surrounding double quotation marks. This can be useful when writing .ini files that are read by applications that do not expect double quotation marks around string values.
05-02-2019 10:35 PM
Thanks Roberto for your tip! It's good you added it because the method I included in my attachment to my previous post for fixing this issue actually did not work. So I've modified a few lines to use Ini_SetAddQuotesToStrings() as you suggest which takes care of the same problem. This function returns the previous state of the "AddQuotesToStrings" parameter which by default is 1 so keep that in mind if you are tracking errors.