- NSIS Discussion
- NSISdl macros
Archive: NSISdl macros
Afrow UK
8th August 2003 16:10 UTC
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
Joost Verburg
8th August 2003 16:16 UTC
Looks nice. Maybe think of something better instead of run-time URL splitting.
Afrow UK
8th August 2003 16:20 UTC
It fitted what I needed, but what woud you mean by that?
-Stu
Joost Verburg
8th August 2003 16:49 UTC
You are splitting parameters on run-time, that adds size to the installer.
Afrow UK
8th August 2003 17:31 UTC
How would I be able to go about this?
-Stu
Afrow UK
14th August 2003 21:48 UTC
Ok, so I should use !system, and split the string on compile time, rather than on runtime. Will this work?
-Stu
Joost Verburg
14th August 2003 22:22 UTC
That's indeed better.
Afrow UK
14th August 2003 22:59 UTC
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
deguix
15th August 2003 00:23 UTC
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...
kichik
15th August 2003 11:02 UTC
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.
Afrow UK
15th August 2003 11:07 UTC
That's a great idea Kichik!
Very simple solution that is much better than current.
-Stu
Afrow UK
15th August 2003 11:57 UTC
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:
kichik
15th August 2003 12:25 UTC
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.
Afrow UK
15th August 2003 12:32 UTC
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
Afrow UK
15th August 2003 12:33 UTC
Wait, placing two fake urls in screws it up (doesn't get to "urls_start")
I'll find out why...
-Stu
Afrow UK
15th August 2003 12:37 UTC
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
Afrow UK
15th August 2003 12:40 UTC
I've ended up using this to fix it:
Push $R0
Exch $R0
Everything works great now.
-Stu
kichik
15th August 2003 12:41 UTC
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
Afrow UK
15th August 2003 12:41 UTC
Here is latest script:
[edit]Removed SplitString function[/edit]
-Stu