Archive: Custom page loop


Custom page loop
I have written a custom page that contains a DirRequest box that can be populated either by a directory browser or by manually typing a directory path.

The code for this page tests if the last directory in the path is a specific word. If it is, then allow the Install button to proceed. If it is not, then pop up a message box with instructions. After Okaying the button, stay on the page and let the user try again.

The way I do this is to have the function call itself. Recursion seems like the wrong approach but it works - almost. I have been unable to figure out a way to make the Back and Cancel buttons behave as expected.

Keeping track of the state of the DirRequest is not sufficient because these buttons should be able to do their actions regardless of its state. But I don't see how to work around this.

This seems like a fairly normal operation and I would have expected to find some info on it but I've come up empty. I'd appreciate any help.


You can use a "leave" function to keep the user at your custom page until the necessary information has been entered.

See the NSIS User Manual for information and some sample code:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.5.3


Oddly enough, I had already tried the "leave" function and was not getting the expected results. I thought it may have had to to with the fact that my page didn't have a Next button but an Install button. I was verifying this condition as I was writing this and suddenly it began to work. I'm not usually in favor of Then a Miracle Occurs code but unless the problem re-manifests I'll just mush on.