Archive: $var and !define, help


$var and !define, help
I have this:
!define 0 "bla0"
!define 1 "bla1"
... until 9

after math operations, the awnser is save
in the "$R0" variable...
I wanna display a messagebox with the awnser the
text predefined above..
if the awnser is "0" displays "bla", like this:


MessageBox MB_OK "${$R0}"
;where $R0 is the awnser but I'll display the text predefined

But it doesn't work... any ideas? :winamp: :)

I beleave, that is because that the ${} don't support variables on it, like you !define ABOUT$R0, will show that you defined ABOUT$R0.


Defines are compile time and variables are runtime. NSIS can't possibly guess what $R0 will hold when running the code.

You'll have to either use a lot of StrCmps, or if you want to make a shortcut, create an array using System.dll, set the right values in every cell and get the requested value by the offset (0, 1, ...).


In my case how can I make that array....
I know what array is :), but can I implement with the system.dll


On second thought, using lots of StrCmp will be a lot easier. Making a little macro for it will help shorten it up.


Ok thanks...I'll work with the StrCmp in Macros
:)


OK...in this thread was about
!define --> $var ... ok...
can be $var --> !define (without be declare)?


When you define A as B the compiler will just replace textually, on compile time, every occurrence of ${A} with B. Therefor bl${A} will become blB, ${A}ringToFront will become, and treated as BringToFront, etc. The value of the definition does not change on runtime. The installer doesn't even know there was a definition there.