Archive: A demo, a bug (?) and a question


A demo, a bug (?) and a question
Here is a demo which might help others coding in NSIS. Sorry to those who who wrote it, but there are a few places in the NSIS documentation which could benefit from more clarity (I'll post some suggestions on the CVS site eventually). This demo might help with a couple of commands whose use I initially struggled with. It uses Goto $n in a loop where $n, the target-address of the Goto, is incremented with each loop iteration, thereby implementing a crude form of case structure in NSIS. The initial value of $n is set by GetLabelAddress. The source code, which is heavily commented, is included in the zip. Examine it for more information. In addition, it includes a function named StrParse, which, IMHO, might be worthy of inclusion in the "Useful Functions" section (Appendix C) of the documentaion.

However the attachment also demonstrates what I think could be another manifestation of an NSIS bug originally reported here (and subsequently fixed by kichik). I was experimenting with the Page command whose documentation (4.3.1) says can be used to rearrange the page ordering and even show the same page more than once. However, the following code produces weird results:


; I *think* this is a bug in NSIS:
; Page License ; When enabled, these 4 lines should have the effect (in
; Page Instfiles ; this case) of running the program twice, but some of the
; Page License ; buttons (next, continue, back, close) loose their button
; Page Instfiles ; text. Also, the back button on page 3 doesn't work.

Try running the second version of the .exe (renamed BugDemo.exe) included in the zip, and observe the buttons.

It is possible the bug lies in my understanding of the documentation (I'm afraid I don't quite understand the use of the terminology "callback function" -- who is calling who back? :confused: ) Maybe there is something else I have to do to make this work as intended. But in case it really is a bug, I thought I should point it out.

Kichik, a question: Is it possible to have two DIFFERENT license pages (each one with its own LicenceData and with a different LicenseText, button_text?) I am currently doing something like that by compiling separate .exes and having the first exec the second just before terminating. Then it occurred to me that the Page command might be able to achieve the same thing in the one .exe. Can it be done?

Fixed both bugs:
1) Install log dialog not being destroyed.
2) Next button text not added.

A callback function is a function that is not called by you rather by the installer "automatically".

Kichik, a question: Is it possible to have two DIFFERENT license pages (each one with its own LicenceData and with a different LicenseText, button_text?) I am currently doing something like that by compiling separate .exes and having the first exec the second just before terminating. Then it occurred to me that the Page command might be able to achieve the same thing in the one .exe. Can it be done?
That should be avaiable in the next version. For now you can change the visiblity of sections and show the components page twice (or more), save $INSTDIR to another variable and show the directory page twice (or more), and disable/enable different sections and show the install log page twice. To change the text use SendMessage ${WM_SETTEXT}.

Thanks

Originally posted by kichik
Fixed both bugs:
1) Install log dialog not being destroyed.
2) Next button text not added.
Thanks! I downoaded makensis.exe (1.112) on its own from the CVS but when I replaced the old .exe with the new one, and tried to recompile BugDemo.nsi, MakensisW complained that it could not initialize makensis ("make sure makensis is in the same directory as makensisw"). I then downloaded to latest MakensisW as well and replaced the old one, but that didn't help either. (Error: filename is not a valid Win32 application). I was trying to avoid downloading the entire snapshot and reinstalling NSIS, but in the end that's what I had to do. Does this mean that you can't "mix and match" different file versions from the CVS? (or that it's dangerous to do so?) I thought the point of being able to browse individual files was so you could just download the essential changes. Anyway, reinstalling worked (and the bug is fixed), so all's well.

The browse possiblity is only to view the files online, it isn't meant to download only changed files. If you wish to download only changed files use a CVS client such as Tortoise (find explanations in the FAQ).


Re: A demo, a bug (?) and a question

Originally posted by Mottel
Here is a demo which might help others coding in NSIS.
I noticed that the Demo.zip attachment has been downloaded a few times since I was last here. So, if this applies to you, be warned: there are bugs in the code. (I should have spent more time testing it.) It works fine for the purposes of the demo, but a logic error means that if you want to re-use that code for real-life string/parameter parsing, don't! It will fall down if it encounters representations of null sub-strings within the string (e.g. abcd "" ijkl). (It assumes that it has reached the end of the string!) This is no good for parsing command lines which may include optional parameters. I'm attaching here a new demo which is an improvement in several ways. The code that stores the items into variables is now a reusable function on its own, and can be used for a variety of purposes. Also, the demo now takes its input from an input file, which you can keep open in a notepad window to vary the input as you try out the demo. (If the input file is not there at first, it creates a default one.)

Originally posted by kichik
That should be avaiable in the next version. For now you can change the visiblity of sections and show the components page twice (or more), save $INSTDIR to another variable and show the directory page twice (or more), and disable/enable different sections and show the install log page twice. To change the text use SendMessage ${WM_SETTEXT}.
Thanks for the tip. I'll experiment with it when I get a chance, but I won't be able to do so for a another week or two. Hope you don't mind if I ask for more details later on.