Jump to content

IniRead: double quotes stripped from key value

Guest alastair.cameron

Recommended Posts

Guest alastair.cameron

I have an INI file which contains key values with embedded double quotes. The key values are command lines which may contain parameters which are long filenames (and hence have double quotes around them).

When I use IniRead to read a value, if the value has a double quote at the beginning of the key value, the quotes are stripped from the beginning/end of the key value. If the key value begins or ends with another character, everything seems OK.

Is this a bug?



Test.ini. Section name [install].

Using the command:

$g_InstallCmdLine = IniRead($g_iniConfigFilename, "Install", "InstallCmdLine", "")

$g_InstallCmdLine looses the " at the beginning and end of the value.


InstallCmdLine="E:\DIW 8.0\CD-ROM\setup.exe" /s /f1"E:\Vss\DevKingston\BuildManager\Automated Test\install.iss" /f2"E:\Vss\DevKingston\BuildManager\Automated Test\silent_install.log" /verbose"E:\Vss\DevKingston\BuildManager\Automated Test\verbose_install.log"

Link to post
Share on other sites

The pure syntax for INI files requires you to quote the values, and omitting the outer quotes is just shorthand.

So what you're noticing is not a bug ... but a feature! (seriously :whistle: ).

See, you may want to specify a parameter with spaces on the ends: suppose you want to pass in the word fred with a trailing space. This is actually "fred " (ignoring the quotes. That's what INI files do too .. they ignore the outer quotes, if there is a pair.

All you need is to wrap your value in another set of quotes .. which INI file processing will strip, leaving the ones you want intact.

Experiment with the following INI file (for illustration, read # as a space):


Assuming you read each value into $sX, display it with

msgbox (0,"","|" & $sX & "|")
Edited by trids
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...