Archive: .onVerifyInstDir help (bug ?!!!)


.onVerifyInstDir help (bug ?!!!)
Function .onVerifyInstDir
StrCpy $4 "a.exe"
IfFileExists $INSTDIR\$4 Good
MessageBox MB_OK|MB_ICONSTOP "file does not exist"
Abort
Good:
FunctionEnd

This seems to produce the messagebox twice.
Is that a bug ?
Is there a work around it ?

Thank you in advance


Search the Forum. It has been discussed before. Workaround: use .onNextPage and .onPrevPage to script an alternative .onVerifyInstDir. Use RegCodeNew or MultIni4 (keywords for search, or find them in the NSIS Archive) for example scripts.

-Hendri.


Found solution (using counter variable)
Thanks for the reply Hendri,

I did not look at your pointers since I found a
work-around for .onVerifyInstDir here it is:

Function .onVerifyInstDir
IntOp $1 $1 + 1 ; increment counter (was init to 0)
IntOp $1 $1 % 2 ; possible values of $1 0 and 1

IfFileExists $INSTDIR\poop.exe skip2
IntCmp $1 1 skip2 ; if I compare to 0 then install button is
;not disabled (weird !!)
MessageBox MB_OK "poop.exe not found $1 times"
; display $1 just for testing
Abort
skip2:
FunctionEnd


PS. Is there a place to report the NSIS bugs ?


See http://www.clantpa.co.uk/nsis/wiki/
for a bug report place.

-Hendri.


Sorry kont, it does not work. Try this: type in the dirselect box 'c:\p' and the installbutton is activated. Click it and it will be installed. Typing another character leads to a messagebox. Then typing another allows to click install again etc...

The reason for the two messageboxes in the first place is that the return from "Browse" triggers the .onVerifyInstDir, but also the "EditBox.onChange" (this is done to check dirs when typing something in the editbox). Already a long time ago (I guess in november 2001 :)) I asked if these two routines could be removed and replaced by one: triggering .onVerifyInstDir only at clicking the button "install". This never happened, I already forgot why actually...

But now we have .onNextPage, we can replicate this behavior and activate an alternative .onVerifyInstdir only when clicking install. The first version of this alternative construction can be found in RegCode. Later on this construction has been implemented in MultIni4 and using MultIni4 again in RegCodeNew (both in the NSIS Archive). MultIni4 allows for an easy integration of custom pages and constructions like the alternative .onVerifyInstDir into your installer. Check the function onPageExit and read the comments how to handle it.

[edit]
Haha :) I found my post about .onVerifyInstDir from the past. It was in October :). Nice to read something from the past. Justin actually never replied. So nothing happened to the behavior of .onVerifyInstDir and no new function .onClickInstall, but that is not necessary anymore thanks to .onNextPage :D.
[/edit]

Good luck,
-Hendri.


I did not have time to look at it yet,
but, Thanks for the note Hendri !!


.onVerifyInstDir should be used just to enable the install button.

From the docs:

This callback enables control over whether or not an installation path is valid for your installer. This code will be called every time the user changes the install directory, so it shouldn't do anything crazy with MessageBox or the likes. If this function calls Abort, the installation path in $INSTDIR is deemed invalid.
If you want to let the user know what kind of directory he needs to pick use DirText.

The problem is that you are using .onVerifyInstDir the wrong way... If you want a message box after the user chose his directory you would have to use .onNextPage like Smile2Me said.

I will try to fix that two calls to .onVerifyInstDir bug in my next version of NSIS 1.99.

You are right it does say that in the
docs. I guess I did not pay careful
attention to that paragraph.

Thanks you kichik