sasankad
sasankad

Reputation: 3613

Accessing variables declared in another file

I'm a newbie to NSIS and started working with CoolSoft NSIS dialog Designer to create custom pages for my installer. I have a requirement to hide/unhide some textboxes according to user's selection from a dropdown box. I have included my the custom page in my main nsis script file but seems like i cannot access the variables defined in my custom page.

So my question is whether it's possible to access a variable defined in another script which is included in the current script?

Upvotes: 0

Views: 806

Answers (3)

Anders
Anders

Reputation: 101736

All variables in NSIS are global, you should be able to use any variable after it has been declared:

foo.nsh:

var myvar

bar.nsi:

!include foo.nsh
...
section
strcpy $myvar "baz"
sectionend

Upvotes: 1

Slappy
Slappy

Reputation: 5472

Use /GLOBAL flag for declaring variables - they will become visible from everywhere.

Var /GLOBAL myVariable

If you want to use Symbols (not variables) from different script file then you need to use !include to tell compiler to use symbols from that file.

!include "LogicLib.nsh"

Upvotes: 1

Seki
Seki

Reputation: 11465

If you declared the variable inside of the custom page, did you declared the variable as global? The manual states for variables that:

variables defined in a section or a function must use the /GLOBAL flag. The /GLOBAL flag is not required outside of sections and functions.

Upvotes: 1

Related Questions