Skip to content
⌘ NSIS Forum Archive

anyway to escape ! to write !addincludedir to a file

11 posts

FoBoT#

anyway to escape ! to write !addincludedir to a file

i want to write the !addincludedir command into a text file from a .nsi

is there a way to either use $\ or quotes so that at compile time the !addincludedir command isn't processes by the compiler?

FileWrite $0 '"$\!"addincludedir $${NSISDIR}\2008\Source\$${APP_NAME}$\r$\n$\r$\n'


thank you
🧟

*EDIT*
i misunderstood the compiler error, it appears it doesn't like the $${NSISDIR} or at least teh $$ part
is there a way to escape ${NSISDIR} properly? i thought you just added another $
Joel#
Wait!!!
FileWrite $0 '"$\!"addincludedir $${NSISDIR}\2008\Source\$${APP_NAME}$\r$\n$\r$\n'
addincludedir is only a compiler directive....try a define instead:
!define TMP_PLUG "C:\\put\\a\\path\\fully\\qualify"
; later I can use
!AddIncludeDir "${TMP_PLUG}"
; Even in
FileWrite $0 ${TMP_PLUG} 
FoBoT#
i am trying to write a template (.nsi) using FileWrite, the parts i want to write out to the template are "!addincludedir" and "$${NSIS}" so that those are in the template when i later compile the .nsi program the template was used to start

i'll try a define like

!define THATTHING "!"
!define ANOTHERTHING "AddIncludeDir"
!define YETANOTHERTHING "$$"
!define THELASTTHING "{NSIS}

FileWrite $0 ${THATTHING}${ANOTHERTHING}
FileWrite $0 ${YETANOTHERTHING}${THELASTTHING}

but at some point it might be easier to write .vbs to write the template and just fire the .vbs from my .exe

thank you
FoBoT#
i don't want !addincludedir to be executed by the compiler, i want to write it to a text file

same with ${NSISDIR}

but i worked around the issue with another way

i was trying to see if there was a way to write anything/everything to a text file, things the compiler would normally view as commands, but since it was contained in a filewrite command, it would ignore it
FoBoT#
just to clarify, i was misreading the compiler error at first, this works, you get !addincludedir in your .nsi file

Name "test"
OutFile "test.exe"
Section "Test"
FileOpen $0 template.nsi w
FileWrite $0 "!addincludedir"
FileClose $0
SectionEnd 
but if you do this, you get the error "1 warning:
unknown variable/constant "C:\Program" detected, ignoring (E:\tmp\test.nsi:5)" and you get $C:\Program Files\NSIS in your file

Name "test"
OutFile "test.exe"
Section "Test"
FileOpen $0 template.nsi w
FileWrite $0 "$${NSISDIR}"
FileClose $0
SectionEnd 

the extra $ in front of ${NSISDIR} doesn't escape ${NSISDIR} the way it does other variables and stuff the way it says in the manual 4.2.4
Afrow UK#
You're right there. $${BLAH} works but $${NSISDIR} does not :S
You should open a bug report.

Stu
FoBoT#
sweet, now i have a workaround if i ever need that again

😁

Name "test"
OutFile "test.exe"
!define DOLLAR $
Section "Test"
FileOpen $0 template.nsi w
FileWrite $0 "${DOLLAR}${DOLLAR}{NSISDIR}"
FileClose $0
SectionEnd