Hi NSIS coders,
I started declaring variables right in the functions where I am using them afterwards. Those functions are written down below the sections, where I use those variables as well. The whole installer consists of one .nsi file.
Actually NSIS reports some warnings (unknown variable/constant detected). This is confusing. Is this allowed or not? My understanding of a GLOBAL flag would lead to no warnings. Am I right???
code:
section -main sec_idx
${If} $var1 = 1
...
${EndIf}
sectionend
function foo
var /GLOBAL var1
ReadRegStr var1 HKCU ...
functionend
Declare variables with /global flag
5 posts
Re: Declare variables with /global flag
Sorry that I am not answering your question, but your sample code has errors.
Sorry that I am not answering your question, but your sample code has errors.
Originally posted by saschagottfriedYou have to use double equals "==" otherwise you just assigned $var1 to "1" (I think?)
${If} $var1 = 1
ReadRegStr var1 HKCU ...$var1 not var1
CrushBug I think you should read the comments in the LogicLib.nsh file.
Just use Var without /global at the top of your script.
-Stu
Just use Var without /global at the top of your script.
-Stu
It generates a warning because if you have a function/section/etc. that uses the variable before the function that declares it, it is unknown and will be an error.
Originally posted by Afrow UKYeah, that was why I through in the last minute "I think" in there. Its a coding standard here to use == since most of the other programmers are C programmers. It screws them up to see only 1 = 🙂
[B]CrushBug I think you should read the comments in the LogicLib.nsh file.