Skip to content
⌘ NSIS Forum Archive

Help : How to replace character in a string ?

4 posts

eipimun#

Help : How to replace character in a string ?

Hello,

I’am writing a installer which must insert a line in a given configuration file called “protege.properties”
The differents directories in file path must be separated with “\\” (double slash) (according this kind of configuration file syntaxe)
I’ve got the beginning of the path in the $INSTDIR variable be with only “\” (see following code)


============================================================
Section "GraphViz (2.8)"
…
FileOpen $0 $INSTDIR\applications\protege\protege.properties a
FileWrite $0 "dot.command="
FileWrite $0 $INSTDIR
FileWrite $0 "\\Graphviz\\bin\\dot.exe"
FileClose $0
SectionEnd
============================================================

I’ve got a compiler error (using the ${wordReplace} function) with this code :

============================================================
Section "GraphViz (2.8)"
…
${WordReplace} $INSTDIR "\" "\\" $modifiedInstDir
FileOpen $0 $INSTDIR\applications\protege\protege.properties a
FileWrite $0 "dot.command="
FileWrite $0 $modifiedInstDir
FileWrite $0 "\\Graphviz\\bin\\dot.exe"
FileClose $0
SectionEnd
============================================================

Any one could show me a sample of rigth piece of code ?

Regards

Eipimun
CrushBug#
I think you are missing a parameter.

E.3.8 WordReplace
${WordReplace} "[string]" "[word1]" "[word2]" "[E][options]" $var
You are doing:
${WordReplace} $INSTDIR "\" "\\" $modifiedInstDir
when it should be
${WordReplace} $INSTDIR "\" "\\" "OPTIONS" $modifiedInstDir
I am doing a line almost exactly like yours, only it reads:
${WordReplace} $INSTDIR "\" "\\" "E+" $modifiedInstDir
Try that.