Old 27th February 2010, 15:38   #1
vogliadicane
Junior Member
 
Join Date: Feb 2010
Posts: 11
abort in leave function should force to reload the page

I have one page where the user is requested to download some files by links given on the page.

In the leave function of this page I check if all files are present, if not Abort.
What happens (as expected is) that the page is only NOT LEFT, which means stays as it was before.
But I would like to have it reloaded, because some parameters for dinamically creating the page have changed so far, e.g. the user has downloaded some of the files so the links still present on the page are not needed anymore.

So is it possible to force the page to reload when abort is executed in the leave function?

(I´ve tried to call the show function of this page but that makes the installer crash)
vogliadicane is offline   Reply With Quote
Old 27th February 2010, 19:50   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
You don't need to use a leave function to do this. Just use a loop in your custom page function and generate the page again if some files are missing.
pengyou is offline   Reply With Quote
Old 28th February 2010, 08:58   #3
vogliadicane
Junior Member
 
Join Date: Feb 2010
Posts: 11
not shure, if I get you right. For the "show" function of this cusom page I HAVE a loop, checking for every file if present, and if not an entry for link and text is generated in the ini fields. This works right.
The thing is, I don´t know how to invoke this show function again, if the user did not download some files, when he wants to leave the page (so the page should be shown again updated to the new situation).
To your post, I don´t know how to generate the page AGAIN.
vogliadicane is offline   Reply With Quote
Old 28th February 2010, 09:59   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
I think he means jumping back to the beginning of the page creation function after nsDialogs::Show finishes.

Unrelated question: Why don't you use a download plugin to download the missing files automatically?
MSG is offline   Reply With Quote
Old 28th February 2010, 11:19   #5
vogliadicane
Junior Member
 
Join Date: Feb 2010
Posts: 11
these must be downloaded manually (for legal reasons), ad clicks and so... all others are downloaded automatically

btw I´m using InstallOptions..
here´s my code (truncated):

Function ShowCustomMan
StrCpy $MaxField 1

${ForEach} $R1 1 8 + 1
StrCmp $FileXPresent 0 +1 +6
WriteIniStr "$PLUGINSDIR\man.ini" "Field $R1" "State" "${FileX_URL}"
WriteIniStr "$PLUGINSDIR\man.ini" "Field $R1" "Text" "FileX"
StrCpy $FileXPresent 2
IntOp $MaxField $R1 + 1
Goto End

... other file exitence checks and writeinistr...

End:
${Next}

StrCmp $MaxField 9 Skip +1
${ForEach} $R1 $MaxField 8 + 1
WriteIniStr "$PLUGINSDIR\man.ini" "Field $R1" "State" ""
WriteIniStr "$PLUGINSDIR\man.ini" "Field $R1" "Text" ""
${Next}
Skip:

StrCmp $MaxField 1 +1 +2
Abort
InstallOptions::dialog "$PLUGINSDIR\man.ini"
Pop $0
InstallOptions::show
Pop $0
FunctionEnd

edit: for information $FileXPresent is the variable that is updated to 1 in the leave function, if the file now exists.

I don´t get, how to jump back to this function, when leaving the page and some files are still missing, sorry, if I´m repeating myself, but I think there´s something basic I don´t get here...
vogliadicane is offline   Reply With Quote
Old 28th February 2010, 13:28   #6
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
You should have mentioned you were using InstallOptions earlier. Here is a simple example of the idea I suggested you try:
code:
Function ShowFileList

loop:
StrCpy $0 0

IfFileExists "$PLUGINSDIR\file-1.exe" check_2
IntOp $0 $0 + 1
WriteIniStr "$PLUGINSDIR\sfl.ini" "Field $0" "Text" "Download file-1.exe"

check_2:
IfFileExists "$PLUGINSDIR\file-2.exe" check_3
IntOp $0 $0 + 1
WriteIniStr "$PLUGINSDIR\sfl.ini" "Field $0" "Text" "Download file-2.exe"

check_3:
IfFileExists "$PLUGINSDIR\file-3.exe" check_4
IntOp $0 $0 + 1
WriteIniStr "$PLUGINSDIR\sfl.ini" "Field $0" "Text" "Download file-3.exe"

check_4:
IfFileExists "$PLUGINSDIR\file-4.exe" show_page
IntOp $0 $0 + 1
WriteIniStr "$PLUGINSDIR\sfl.ini" "Field $0" "Text" "Download file-4.exe"

show_page:
StrCmp $0 0 all_done
WriteIniStr "$PLUGINSDIR\sfl.ini" "Settings" "NumFields" "$0"
!insertmacro INSTALLOPTIONS_DISPLAY "sfl.ini"
Goto loop

all_done:
FunctionEnd

pengyou is offline   Reply With Quote
Old 28th February 2010, 14:49   #7
vogliadicane
Junior Member
 
Join Date: Feb 2010
Posts: 11
hmm more elegant than my way. But isn´t it creating an infinite loop I mean one which hangs up the machine, if some file is missing?
Anyway thanks I´ll give it a try!

edit: No loop! Integrated the "Loop .... Goto Loop" into my script and it works! Seems the INSTALLOPTIONS_DISPLAY macro stops until some notify event happens!

So this was exactly, what I was looking for, Thanks!
vogliadicane is offline   Reply With Quote
Old 1st March 2010, 11:59   #8
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Glad to hear that you have managed to solve your problem.

Sorry my first reply did not go into much detail. INSTALLOPTIONS_DISPLAY and its companion macro INSTALLOPTIONS_DISPLAY_RETURN are documented in the InstallOptions2 Readme installed with NSIS. The Readme is also available online:
http://nsis.sourceforge.net/Docs/Ins...ns/Readme.html
pengyou is offline   Reply With Quote
Old 1st March 2010, 20:24   #9
vogliadicane
Junior Member
 
Join Date: Feb 2010
Posts: 11
no prob, actually it´s me who is to blame I have the readme but obviously didn´t read accurately. And I really beleived, a code like that would hang up the machine. next time I´ll just try. (I´m just beginning to script NSIS)

Anyway thanks for help again
vogliadicane is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump