Archive: NSISdl macros


NSISdl macros
I was using NSISdl to download multiple files throughout my installer, so I figured that it would be easier to make a macro (with error/success/cancel messages and all) without having to repeat the same code so many times (in different functions/sections).

I've attached it below, any suggestions, comments, or changes would be much appreciated.

I'm not sure if there are any similar macros to my ones, but it would be cool if it was included with NSIS :)

-Stu


Looks nice. Maybe think of something better instead of run-time URL splitting.


It fitted what I needed, but what woud you mean by that?

-Stu


You are splitting parameters on run-time, that adds size to the installer.


How would I be able to go about this?

-Stu


Ok, so I should use !system, and split the string on compile time, rather than on runtime. Will this work?

-Stu


That's indeed better.


Ok, I have no idea how to use !system, or split a string on compile time (using NSIS script)

Help would be much appreciated.

-Stu


Is difficult to explain. [EDITED]Have to be much changes in your macros, is too much confuse. I don't make a better function now because I don't have a "my computer" (using only public computers).

Is better look the new version of function "Detect System Language" that I will launch tomorrow, I will use macros to don't use any space when you don't need the function and some other useful great features...


The simplest way would probably be letting the user push the URLs instead of supplying them as an argument to the macro. Use something like:

START_URLS
Push url
Push url2
...
END_URLS

START_URLS should push a certain string that will specify the end of the URLs list.


That's a great idea Kichik!
Very simple solution that is much better than current.

-Stu


I've got this working, but have had problems.
I'm popping NSISdl's return value from the stack, which is coinciding with the urls on the stack.
Using Pop in some places made the Invalid opcode error appear, so I replaced some with Exch (NSISdl return value pop and URLS pop)

It seems to work now, but it would be nice if somone could check the script for me:


Invalid opcode error is caused by Exch, not Pop. It happens if Exch is called and the stack is empty/not large enough. I don't think there should be any problem with NSISdl pushing stuff on the stack as long as you pop them all.

You can also use the pushed items for NSISdl instead of popping and pushing them back.


Well, I was having the Invalid opcode when Popping NSISdl's return value before Pushing the variable (or somthing) onto the stack first.
I knew it was the Pop because I placed messagebox before and after it; only the one before it would appear and then the error.

I think that it looks ok and it must be working ok - it definately gets hold of "urls_start" on the stack after trying all urls.

-Stu


Wait, placing two fake urls in screws it up (doesn't get to "urls_start")

I'll find out why...

-Stu


Ok you are right, it's actually the Exch at the end of the script causing it.
Why is this, and how can I fix it?

-Stu


I've ended up using this to fix it:
Push $R0
Exch $R0

Everything works great now.

-Stu


It happens if Exch is called and the stack is empty/not large enough. For example, calling Exch when the stack is empty will trigger this error message. This will too:

Push a
Push b
Exch 2


Here is latest script:

[edit]Removed SplitString function[/edit]

-Stu