5
votes

Is there anyway to include file by mention it with variable? I mean

StrCpy $1 "bla.nsh"
!include $1

?

or maybe getting value of variable that called by another variable such as:

StrCpy $1 "EN"
StrCpy $2 ${LANG_${1}_WELCOME_MESSAGE}

?

Thanks.

2

2 Answers

4
votes

Variables can only be used at runtime (running on the end-users machine), you need to use defines:

!define foo "bar"
!include "${foo}.nsh"

Edit:

You should be using the LangString instruction if you want to add custom translated strings, you can access a langstring at runtime with $(mystringid).

3
votes

Actually, Anders right. Think about that, when the compiler compiling your code, it need to know which files it need to include with your EXE file.

About the variable, you can use only with defines. again, because when you are compiling, the compiler will compile all the needed (in use) variables / defines, and you can't tell him use one that never been declared.. its little different from server side languages because here you are compiling and pack your code into EXE file which is assembled in your computer.