Skip to content
⌘ NSIS Forum Archive

Urgent! Requset for user defined variables

6 posts

ansonding#

Urgent! Requset for user defined variables

Greetings!

I would like to know that whether there is possible or not for using user own defined user varibles instead of using of $0-$9 and $R0 - $R9 NSIS's variables. Because I need more user varibles to declare and hope that I can declare myself to make it more meaningful.

Can anyone give me of guide line or advise. Thanks!!
deguix#
You cannot create more variables, but you can push these variables to stack and when you are finished with them, pop them back:

Push $0
Push $1
# use $1 and $0 here...
Pop $1
Pop $0
# $0 and $1 are same as before the push now 
(used a example by Kichik)
Guest#
You can create more variables (or should I rather say constants):
!define myConstant '4.3'

This might release some variables that you used up to this time for eg the version number. Besides that, writing parts of your installer in a function that doesn't user variables (by putting the original values on stack and retrieving them afterwards) might help. See the example of deguix.

Good luck,
-Hendri.
RDaneel#
While this won't give you *more* variables, you do mention "more meaningful", so...

!define NumberOfFiles $R3

You would reference this as

Pop ${NumberOfFiles}

StrCpy ${NumberOfFiles} $R0

DetailPrint "Files = ${NumberOfFiles}"

etc.
fraefel#
Hi !

As you've stated yourself, the "variables" defined by "define" would become constants; has there been any thoughts of the possibility of free "usernamed" variables ? Would it hard to program ? What are the challenges (there must be some since it hasn't been made yet ;-)...

Originally posted by Smile2Me
You can create more variables (or should I rather say constants):
!define myConstant '4.3'

This might release some variables that you used up to this time for eg the version number. Besides that, writing parts of your installer in a function that doesn't user variables (by putting the original values on stack and retrieving them afterwards) might help. See the example of deguix.

Good luck,
-Hendri.