Archive: How many variables?


How many variables?
i'm having an installer that uses InstallOptions excessively. it will write each value to an ini file.

nsis offers me the variables $0-$9 and $R0-$R9. i'm not sure how to write more than 20 values to the ini, when i have only 20 variables. i guess it somehow works with pop/push, but i never understood this anyway.

maybe an example of how to accomplish the task without wasting variables.


I don't know anything about ini files, but I do understand how pop and push work. Hopefully that will be of some use.

I believe the function names 'Pop' and 'Push' come from the assembly commands of the same name (I don't know why they were named this way). In NSIS, 'Push' will push a string onto the stack, and 'Pop' will pull it off the stack. You can think of it like a stack of bricks. The more you put on the stack, the more you have to take off to get back to the original brick.

Something else that might help is to think of it like a backwards queue. A queue is a FIFO (First In First Out) system, whereas a stack is a LIFO (Last In First Out) system.


Great description ctlajoie. I think there are a lot of metaphors that work. I don't know if you buy bread or milk killahbite, but at the grocery store people buy these things. On their packages are expiration dates, usually named "Best by Date x." In general, the deliveries for these items are daily or every other day but the entire stock never sells that fast. The result is that there may be old product on the shelves. The grocery store knows this and because they want to sell it before it goes bad the move the older stuff to the front (First in, first out). Conscientious buyers however, often dig around and look in the back for the newest delivery, the fresher milk or bread, eggs or whatever. The result is that buyers create a LIFO system, last in first out system. The last carton of milk put on the shelf is the first one people try to take off, because it is freshest.

This is the way the stack works. The last variable you push to the stack is the first one you get when you pop a variable off of the stack. When you look at functions in the archive you will usually see them start off like this:
Push $1
Push $2
Code using $1 and $2
Pop $2
Pop $1

This is because the function needs to use variables but doesn’t want to mess up the values that you may have assigned before you called it. One last thing, the word “push” is a bit of a misnomer. You don’t “push” a value to the stack so much as you copy the value there. Push $1 does not in anyway effect the value of $1 it merely copies $1 to the top of the stack. Popping however does not just copy a value from the stack it moves it from the stack to the variable shifting the remaining values up. To see what this looks like, go here: http://www.sullust.net/sw/dumpstate/ download the dll and copy and paste the code Dumpstate::debug in various parts of your code to see what the variable assignments and stack look like.


uhm, this is getting a bit apart from the original question (i've read such descriptions so often, with no success - yet).

just need to know how to get around that 20 variables limitation. basically i've been wondering if i could do the whole thing by using just one variable (if that's possible!), because i don't need the value of the variable once it's written in the ini file.


You can write other things than variables and the variables can change after you write them. Why do you insist on keeping 20 variables for 20 values in the INI file?