Page 1 of 1

Edit INI File: Writing Backslashes

Posted: Wed Mar 22, 2006 8:50 am
by MikeFieger
Why can´t I write a string that contains a double backslash (\\\\) to an ini file?

I tried writing the string via a variable as well as hardcoded to the 'Edit INI File' command.
The result always has only one backslash no matter how many backslashes I try to write.

This pretty much looks like a bug to me :evil:

Why is this and is there a workaround for this?

Posted: Wed Mar 22, 2006 7:24 pm
by MichaelNesmith
This is actually not a bug, but a feature. InstallAware automatically removes double-backslashes found in variables for you, and replaces them with a single backslash. This is provided as a convenience for when you are forming paths, like $TARGETDIR$\\subfolder. Normally this might be folder\\\\subfolder, or folder\\subfolder, but by eliminating the double backslashes, you don't need to worry about it.

Unfortunately in your case, this is preventing you from writing the actual data you want to write! Sorry! Maybe we can define a special variable to represent a double-backslash in the next version.

Also, you may use the Write to Text File command and hard code a double-backslash. In this case the double-backslash survives (as long as its not in a variable).

Posted: Thu Mar 23, 2006 2:49 am
by MikeFieger
Thank you for your answer.

I would be glad if you could solve this problem in a future release.

Providing a special variable containing two backslashes would work for me but I think this is still not the best solution because one could still not write, for example, 3 or more backslashes to an ini file. (I know this is hypothetic, but hey, a good installer should not restrict the user ;-))

So I think it would perhaps be better to make one backslash out of two. This would keep the current logic, but also enable the customer to write 2 backslashes by typing in 4 (...and 3 by typing 6 and so on).

Please let me know if you plan to solve this problem as I don´t know how I coud use the 'Write to TextFile' command to edit a line in the middle of an ini file.

Greetings,

Mike

Posted: Thu Mar 23, 2006 1:02 pm
by MichaelNesmith
Yes, this will be addressed! Thanks for letting us know.

Posted: Sat Mar 25, 2006 8:12 pm
by MichaelNesmith
An immediate resolution is available for this problem which does not require an update.

If the double-backslash occurs at the start of the string (very first character), do nothing. Double backslashes at the start of a string are accepted.

If the double-backslash occurs anywhere else, use the "magic" sequence of seven backslashes to produce a double-backslash at runtime.

Posted: Mon Mar 27, 2006 4:51 am
by MikeFieger
Tank you!

The "magic sequence" solved my problem :)