- NSIS Discussion
- Variables
Archive: Variables
zip_doo_dah
14th August 2003 23:25 UTC
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
Joost Verburg
14th August 2003 23:27 UTC
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.
deguix
15th August 2003 00:29 UTC
Allowed variables are: $0 - $9, $R0 - $R9, $EXEDIR, $INSTDIR, $LANGUAGE, $OUTDIR ,$CMDLINE, and user variables declared with the Var command.
zip_doo_dah
15th August 2003 00:57 UTC
SWEET!!! Excellent addition to the installer and perfect timing in my case. Thanks a million!
-Justin
dabossuk
15th August 2003 11:34 UTC
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
kichik
15th August 2003 11:40 UTC
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.
Joost Verburg
15th August 2003 12:57 UTC
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.
zip_doo_dah
20th August 2003 15:42 UTC
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
zip_doo_dah
20th August 2003 15:47 UTC
forget it. i think i may have figured it out. thanks anyway.
dabossuk
20th August 2003 15:48 UTC
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 ....
Afrow UK
20th August 2003 15:54 UTC
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