LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Ini Files - Ini_PutString adds \'s to a file pathname string

Hi All,

Im currently trying to save a string that is a pathname using the Ini_PutString() function. When I look at the saved ini file in notepad, the Ini_WriteToFile has added \'s to the pathname, for example, the original string is C:\Mypath, the saved ini file is c:\\Mypath. If the same pathname string is saved again it looks like c:\\\\Mypath etc. It seems to double the number of \'s each time the ini file is saved.

Other strings that dont contain a \ are fine. All the other Ini_Put's work fine too.

I cant figure this one out, got any ideas please?.

Cheerio
Mike
0 Kudos
Message 1 of 3
(3,376 Views)
The reason while \'s are doubled while saving the string to a file is that \x can be interpreted as a control character by the compiler. For example, \n means "new line" and \t means "Tab"; to simply print a backslash, you need to double it to distinguish it from other control codes.
If, \'s weren't doubled, when reading back a string you would get the error "unknown escape sequence \x": having it doubled, instead, the compiler should correctly interpred them and rebuild an exact copy of the original pathname, it's strange what you say about multiple double-backslahes in sequence.

In any case, I suggest you use the "raw" string read/write functions instead of the standard ones.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,372 Views)
Thanks Roberto, the PutRawString() did the trick.

In fact it is clearly explained in the PutRawString() function help but there is no mention of the pit falls of using pathnames with \'s in the PutString() function help. Maybe PutString() help could be elaborated a bit to explain this.

Cheerio
Mike
0 Kudos
Message 3 of 3
(3,357 Views)