Change or Add new Script Location

Posts: 5
Joined: October 3, 2018 - 15:39
Change or Add new Script Location

A big thing that I'm sure a lot of people are doing is skipping pages or showing pages conditionally.

The way it is currently setup you have to manually edit the .nsdinc file

Which is a pain since everything you save the dialog it overrides that file.

To skip a page you call Abort before the page is created. (nsDialogs::Create)

ControlCustomScript comes close but it is inserted right after the nsdialogs call.

Also it would be nice to have an area after the the page is shown (nsDialogs::Show)

I usually have to do some memory clean up after the page is shown. (System.dll calls)

Another area where I have to edit the nsdinc manually.

Personally I feel like the HeaderCustomScript/FooterCustomScript could be what is used for this.

As their current purpose is easily replaced by just adding code before/after the !include Pagename.ndsinc

Posts: 1394
Joined: March 25, 2012 - 01:19
Re: Change or Add new Script Location

I think that the show/skip logic for a page should stay outside the page itself, i.e. in your main script.
The page script should contain everything related to the page itself but it's the caller that's in charge of deciding if that page should be include in setup flow or not.
Beware to not mix roles: the if clause that decides if the page should be shown should be outside the object itself; of course a page should be able to decide which of its controls must be visible but should not decide of its whole existance.

If you still want to go that way you could use this workaround:

  • set GenerateShowFunction property to False (this will not generate the default fnc_xxx_Show function)
  • create your own fnc_xxx_Show function (with the Abort logic) by using the HeaderCustomScript property
Posts: 1394
Joined: March 25, 2012 - 01:19
Re: Change or Add new Script Location

PS: the GenerateShowFunction dialog property will be available in next 1.4.3 version.

UPDATE: version 1.4.3 released.

Posts: 5
Joined: October 3, 2018 - 15:39
Re: Change or Add new Script Location

That workaround is working great. Saving a ton of time not having to redo that everytime I adjust the page.

Thanks for that!

I am curious though if there is a better way to do it.

I think what you are referring to would be to either use Page or PageEx to specify a different function that will determine if the page will display or not.

Page fnc_CustomPage_Pre fncCustomPage_Leave
 
...
 
 
Function fnc_CustomPage_Pre
 
  ;Skip Page if first InstallType
  GetCurInstType $1
  ${If} $1 == 0
    Abort
  ${EndIf}
 
  Call fnc_CustomPage_Show
 
FunctionEnd
 
 
or 
 
 
PageEx custom
 
fnc_CustomPage_Pre fnc_CustomPage_Show fnc_CustomPage_Leave
 
PageExEnd
 
 
Function fnc_CustomPage_Pre
 
  ;Skip Page if first InstallType
  GetCurInstType $1
 
  ${If} $1 == 0
    Abort
  ${EndIf}
 
FunctionEnd
Posts: 1394
Joined: March 25, 2012 - 01:19
Re: Change or Add new Script Location

Yes, sort of.

And you should keep your show/abort logic outside the dialog files.

warning

Warning, JavaScript is disabled!

JavaScript is not available, maybe because you disabled it globally into your browser settings or you are using an addon like NoScript.

We do not have any dangerous JavaScript running here.
Please enable JavaScript; if you're using NoScript this image will help you adding CoolSoft to your whitelist.

Thanks for your comprehension and enjoy CoolSoft.