Archive: how to use StrRep


how to use StrRep
I need to convert $INSTDIR for a Java properties file, so I have to replace the back slashes with forward slashes in the path.

I read about StrRep but I don't understand the syntax for using this function/macro.

In a Function, I write this:


!include StrFunc.nsh
...

Function configure
...

StrCpy $5 $INSTDIR
Push "$5"
Push "\"
Push "/"
Call StrRep
Pop "$6"


...
FunctionEnd


This results in:

Processed 1 file, writing output:
Adding plug-ins initializing function... Done!
Error: resolving install function "StrRep" in function "configure"
Note: uninstall functions must begin with "un.", and install functions must not
Error - aborting creation process


If I called it as the example here, http://nsis.sourceforge.net/StrRep, suggests, I get an argument error.


${StrRep} $5 $INSTDIR "\" "/"


!insertmacro: macro "FUNCTION_STRING_StrRep" requires 0 parameter(s), passed 4!


Can someone please explain how to use/setup. Thanks.

Wiki's StrRep function is a little different from that in StrFunc header. If you use the header, you should use ${StrRep} first outside of sections and functions and before you use it to implement the actual function (or the error you described happens). For else, it's the same.

I plan in the future to replace that header with UseFunc so that this easy inclusion syntax found on this StrFunc header can be exploited more.