Skip to content
⌘ NSIS Forum Archive

FileWrite question

4 posts

Comperio#

FileWrite question

I've been working on an installation that creates an NSH file for another installer. (This allows to get user input at compile time.)

I found an odd problem with FileWrite. (either it's a bug or I'm just being stupid!)

I need to include the actual characters "$\" in the text of the file so that I can get a MessageBox to print multiple lines.

Here's my code I'm currently using:
FileWrite $0 'MessageBox MB_OK "This is one line $$\\r$$\\nAnd this is another line'$\r$\n"

The problem is that I get this as the output:
MessageBox MB_OK "This is one line$\\r$\\nAnd this is another line"

If I use anyting but "$$\\" in my FileWrite command, I get a compiler error that the variable/constanst is undefined.

Is there any way I can get just a single backslash without resorting to using FileWriteByte? (I want to keep things as simple as possible.)
glory_man#
This code works but maybe not the best decision:

StrCpy $1 "\r"
StrCpy $2 "\n"
FileWrite $0 'MessageBox MB_OK "This is one line.$$$1$$$2And this is another line"$\r$\n'
glory_man#
This code also works:

StrCpy $1 "$$"
FileWrite $0 'MessageBox MB_OK "This is one line.$1\r$1\nAnd this is another line"$\r$\n'