Archive: $0, $1 Var Confusion


$0, $1 Var Confusion
Im using default nsis variables in my script and using same var for multiple use like this. So before using 2nd time should I need to clear its content ?.

Actually I read NSIS documentation on this which says about some stack issue thats not clear to me..


ReadRegStr $1 HKLM "Software\xyz" "xyz"
${If} $1 == ""
WriteRegStr HKLM "Software\xyz" "xyz" $2
${EndIf}

ReadRegStr $1 HKLM "Software\xyz" "xyz2"
${If} $1 == ""
WriteRegStr HKLM "Software\xyz" "xyz2" "FALSE"
${EndIf}


Will this piece of code cause an issue for long time ?

No, that code will work just fine, because ReadRegStr will always return an empty string if the regstring doesn't exist. This is clearly stated in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.12

Note: If for some reason you want to emtpy a variable, simply use StrCpy $Var ""


Okay.

What is the significance of Pop $1 or Push $1. I know Pop, Push is related to stack but still wants to know more.


The stack is a "stack" of strings. When you push something on top, it covers everything that's below it. So to get at the second string, you first need to pop the first off the stack, and then the second. It's just a temporary string storage space, "first in last out".

The concept of a stack is as old as PC's. Google should give you some details, but you won't really need it. Just think of it as a stack of papers that you can use to store data.


Yes. Its now clear. Thanks mate.