Archive: Variables


Variables
Hey everyone.
Just curious if the only allowed variables are $R0 - $R9 and $0 - $9. Is this correct? If it is, why can't we have more variables to use. I have some complicated logic that requires a few more variables. Thanks for your help.
-Justin


The latest development version supports user variables, so you can use as much variables as you want (declared with the Var command). For details see http://nsis.sf.net.

There is also the possibility to use the stack.


Allowed variables are: $0 - $9, $R0 - $R9, $EXEDIR, $INSTDIR, $LANGUAGE, $OUTDIR ,$CMDLINE, and user variables declared with the Var command.


SWEET!!! Excellent addition to the installer and perfect timing in my case. Thanks a million!
-Justin


Hi

Having variables is a GREAT new feature :-) ...

is there any reason why you would still need to use Push, Pop etc anymore ? uhm typing being using brian! ... I assume if you want to take add two Var's together MyValue+MyValue2 you could not do this - so you would need to use the stack ? Is the plan to add extra functions to now deal with the new variables ?

Dabossuk


Using the stack is still recommended for functions because functions can have conflicting variable names. It's also good practice in general to not waste too much memory and find better algorithms that manage with a minimum amount of memory.

Adding two variables is possible. What new functions are you talking about? StrCpy, IntOp, StrLen and every other instruction already works with user variables.


Using registers ($0-$9, $R0-$R9) is especially recommended for shared functions and functions that will be distributed (like NSIS Archive code). This will prevent any naming conflicts and save memory.


Wow, I feel pretty stupid. I want to update my nsis install so that I can declare variables with the var command, but my ignorance seems to be blocking my progress. How do I update my nsis to get this to work? I have nsis2.0b3 installed.

- Justin


forget it. i think i may have figured it out. thanks anyway.


Hey a question I can answer ;-)

You need NSIS 2 B4 - which for some reason has not been "offically" released yet - but we are now using.

You can get from - the nightly build of NSIS -http://nsis.sourceforge.net/nightly/nsis.zip just unzip over the top of your NSISB3 install.

Be warned though thath the ModernUI has been changed - so read my posts I made with this problem - the others helped me fix it ;-)

Hope that helps ....


I try not to use custom variables, because it uses up more memory on run-time.

I use defines instead like so:

!define ${VAR1} $0
!define ${INSTDIR2} $1

Function blah
ReadRegStr ${VAR1} HKLM "Software\Quake II" "Install Location"
StrCpy ${INSTDIR2} ${VAR1}
FunctionEnd

-Stu