How can I use variable on NSIS include / to get another variable
Asked Answered
E

2

5

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.

Erwin answered 18/8, 2013 at 17:29 Comment(0)
D
3

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.

Duggins answered 19/8, 2013 at 6:51 Comment(0)
M
4

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).

Monteverdi answered 18/8, 2013 at 17:53 Comment(6)
Got it, but what about my second question? how can I use variable value calling with variable-in-variable (second code i gave)Erwin
StrCpy $2 "foo $1 bar"Monteverdi
You didnt got me. I mean, if $1 contain for ex. "EN" and i have define called LANG_EN_WELCOME how can i get the define with $1? i mean something like ${LANG_${1}_WELCOME} but its doesnt work for me.Erwin
You have to use a define for EN, I already told you, variables cannot be used at compile-time. Syntax: $thisIsAVar ${thisIsADefine} ${thisIs${DefineInside}ADefine}Monteverdi
ok, so maybe you can help me, i want to make my translation for few sentences by user system language.. how can i?Erwin
let us continue this discussion in chatErwin
D
3

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.

Duggins answered 19/8, 2013 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.