Search code examples
stringconcatenationnsis

How do I concatenate a string with the same string in NSIS?


I need to concatenate a string in NSIS that builds a new string with itself.

In C++ I would do something like this:

   if ( h == 0 )
      cout << "No errors\n\n";
   if ( e > 0 )
      err += e1;
   if ( f > 0 )
      err += e2;
   if ( g > 0 )
      err+= e3;

But in NSIS:

strcpy $1 "$1$2"
strcpy $1 "$1$3"
strcpy $1 "$1$4"

doesn't work.

Any suggestions here would greatly be appreciated.


Solution

  • outfile test.exe
    requestexecutionlevel user
    page instfiles
    section
    ;init strings
    strcpy $1 "Hello: "
    strcpy $2 foo
    strcpy $3 bar
    strcpy $4 baz
    
    strcpy $1 "$1$2"
    strcpy $1 "$1$3"
    strcpy $1 "$1$4"
    DetailPrint $1 ;prints "Hello: foobarbaz"
    sectionend