Old 6th September 2010, 12:43   #1
thanatos83
Junior Member
 
Join Date: Dec 2009
Posts: 29
Go to a NSIS page!

HI.

I read the documentation about how to jump a NSIS page, so i need to jump to a page specific if a user select one option u other option.

Well I set this in my script:

PHP Code:
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
Page custom SetupType SetupTypeLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

Function RelGotoPage
  IntCmp $R9 0 0 Move Move
    StrCmp $R9 
"X" 0 Move
      StrCpy $R9 
"120"
 
  
Move:
  
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd 
Them i put this:

PHP Code:
${If} $SelRap == ${BST_CHECKED}
        
StrCpy $R9 3 
        Call RelGotoPage
    
${Else}
        
StrCpy $R9 6 
        Call RelGotoPage       
${EndIf} 

But i confuse because the third page of NSIS is my custom page and then it shows me the install page. What is the order of the NSIS pages that shows with "StrCpy $R9 3" or for example 1,2,3,4, etc... ?

Last edited by thanatos83; 6th September 2010 at 13:14.
thanatos83 is offline   Reply With Quote
Old 6th September 2010, 13:35   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
It's a relative jump. If you pass '3', it should jump three pages forward. So where you end up depends entirely on where you're jumping from.

Also, why on earth would you want to jump 120 pages? o__O
MSG is offline   Reply With Quote
Old 6th September 2010, 13:53   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Going forward any number than there are pages simulates a Cancel click.

Stu
Afrow UK is offline   Reply With Quote
Old 6th September 2010, 15:05   #4
thanatos83
Junior Member
 
Join Date: Dec 2009
Posts: 29
Quote:
Originally Posted by MSG View Post
It's a relative jump. If you pass '3', it should jump three pages forward. So where you end up depends entirely on where you're jumping from.

Also, why on earth would you want to jump 120 pages? o__O
OK, thanks i change this for 8 pages in total... now i see how this work with relative jumps.

But there's also a problem, because the first condition work nice and goes to install files but if i select de second and try to jump to !insertmacro MUI_PAGE_DIRECTORY page then the installer generated an error and exits from installer.

May be it is a bug ?
thanatos83 is offline   Reply With Quote
Old 6th September 2010, 15:17   #5
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
no idea about the crash (might need full example code)... but if you only need to move forward, I'd recommend using the technique of calling Abort in the pages' Pre function. Use a variable to indicate which page you want to land on and call Abort in every page that is not the page you want.
Animaether is offline   Reply With Quote
Old 7th September 2010, 15:40   #6
thanatos83
Junior Member
 
Join Date: Dec 2009
Posts: 29
hi.

I get the same problem... crash if i jump to directory page, maybe the reason is the value 1 of StrCpy $R9 1 because it's reserved value for next page ?.

I put my script, any help please!

PHP Code:
# Página - Bienvenida
!insertmacro MUI_PAGE_WELCOME

# Página - Licencia 
!insertmacro MUI_PAGE_LICENSE $(MUILicense)

# Página - Tipo de instalación 
Page custom TipoInstalacion TipoInstalacionLeave

# Página - Directorio
!define MUI_PAGE_CUSTOMFUNCTION_PRE Directorio_PreFunction
    
!insertmacro MUI_PAGE_DIRECTORY
    
# Página - Menu Inicio
!define MUI_PAGE_CUSTOMFUNCTION_PRE MenuInicio_PreFunction    
    
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
    
# Página - Acceso Directo
Page custom AccesoDirecto
 
# Página - Instalación
!define MUI_PAGE_CUSTOMFUNCTION_PRE Instalacion_PreFunction   
    
!insertmacro MUI_PAGE_INSTFILES
    
# Página - Finalizar    
!define MUI_PAGE_CUSTOMFUNCTION_PRE Finalizar_PreFunction
    
!insertmacro MUI_PAGE_FINISH
    
# Define la función FunAbo    
!define MUI_CUSTOMFUNCTION_ABORT FunAbo

# Páginas de desinstalación
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Function jump pages
Function RelGotoPage
  IntCmp $R9 0 0 Move Move
    StrCmp $R9 
"X" 0 Move
      StrCpy $R9 
"6" ;Nº total de páginas
 
  Move
:
  
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd


# Custom function SetupType
Function TipoInstalacion 
StrCpy $R8 1 
;esta es la primera página
   
!insertmacro MUI_HEADER_TEXT "$(Tit1)" "$(SubTit1)"

nsDialogs::Create /NOUNLOAD 1018
    Pop $CD1

    
${If} $CD1 == error
        Abort
    
${EndIf}       
    
    ${
NSD_CreateRadioButton12u 20u 10020 "$(InstRap)"
    
Pop $Rad2
    
 
# Por defecto selecciona la Instalación rápida
    
${NSD_SetState$Rad2 ${BST_CHECKED}
    
    ${
NSD_CreateRadioButton12u 33u 10020 "$(InstPer)"
    
Pop $Rad1
    
    
${NSD_CreateLabel0u 0u 10020 "$(L1)"
    
Pop $Lab1
    
nsDialogs
::Show        
FunctionEnd

Function TipoInstalacionLeave
# Guarda el estado del control del RadioButton
    
${NSD_GetState$Rad1 $SelPer
    
${NSD_GetState$Rad2 $SelRap

# Condición basada en la selección del RadioButton    
    
${If} $SelRap == ${BST_CHECKED}
        
StrCpy $R9 4 va hacia la página de instalación
        Call RelGotoPage
    
${Else}
        
StrCpy $R9 1 va hacia la página de seleccionar directorio
        Call RelGotoPage       
    
${EndIf}      
FunctionEnd


# Directory page
Function Directorio_PreFunction
  StrCpy $R8 2 
;esta es la segunda página
FunctionEnd

# Startmenu page
Function MenuInicio_PreFunction
  StrCpy $R8 3 
;esta es la tercera página
FunctionEnd


# Custom function Shorcut
Function AccesoDirecto    
StrCpy $R8 4 
;esta es la cuarta página

!insertmacro MUI_HEADER_TEXT "$(Tit2)" "$(SubTit2)"

nsDialogs::Create /NOUNLOAD 1018
    Pop $CD2

    
${If} $CD2 == error
        Abort
    
${EndIf}       
    
    ${
NSD_CreateCheckBox0u 14u 10020 "$(AccEsc)"
    
Pop $Check1    
    
    
${NSD_CreateCheckBox0u 33u 10020 "$(AccIni)"
    
Pop $Check2
    
    
${NSD_CreateLabel0u 0u 10020 "$(L2)"
    
Pop $Lab2
    
nsDialogs
::Show        
FunctionEnd


# Installation page
Function Instalacion_PreFunction
  StrCpy $R8 5 
;esta es la quinta página
FunctionEnd

# Finish page
Function Finalizar_PreFunction
  StrCpy $R8 6 
;esta es la sexta página
FunctionEnd


# Custom function abort
Function FunAbo
  StrCmp $R8 1 0 End 
;Compare the variable with the
                     
;page index of your choice
    StrCpy $R9 1
    Call RelGotoPage
    Abort
  End
:
FunctionEnd 
PD... Sorry for some strings in spanish language i'm spanish
thanatos83 is offline   Reply With Quote
Old 7th September 2010, 21:17   #7
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
Originally Posted by thanatos83 View Post
hi.

I get the same problem... crash if i jump to directory page, maybe the reason is the value 1 of StrCpy $R9 1 because it's reserved value for next page ?.

I put my script, any help please!
Thanks for the semi-full example; it gives us something to work with

Those who want to poke at it, the following is missing (just put it at the top):
PHP Code:
!include "MUI2.nsh"
var StartMenuGroup
var CD1
var CD2
var Check1
var Check2
var Lab1
var Lab2
var Rad1
var Rad2
var SelPer
var SelRap
Outfile 
"$%temp%\temp.exe"

Section
SectionEnd 
On to the issue at hand, then... the problem in your script appears to be that you're calling 'RelGotoPage 1' from your Custom Page's Leave function. You can't do that, as NSIS will get stuck in a loop. Not sure why, but it does

As you only need to go +1 page anyway, you can just -not- call "RelGotoPage" at all, and NSIS will take the user to the next page as usual
Animaether is offline   Reply With Quote
Old 7th September 2010, 23:26   #8
thanatos83
Junior Member
 
Join Date: Dec 2009
Posts: 29
Exactly, i removed the part in the condition:

${Else}
StrCpy $R9 1 ; va hacia la página de seleccionar directorio
Call RelGotoPage
${EndIf}

So it seems NSIS was getting in a constant loop, and now work fine...

Thanks for help
thanatos83 is offline   Reply With Quote
Old 7th September 2010, 23:35   #9
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
No prob I'd still recommend using the other method, seeing as you're only going forward... as you can then easily re-order pages, add/remove pages, etc. without having to worry about updating the relGotoPage index numbers. But this should definitely work
Animaether 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