Skip to content
⌘ NSIS Forum Archive

How to make a NSIS installations in separated files

3 posts

USERDPRO#

How to make a NSIS installations in separated files

Hi all,

I'm working in a NSIS installation that has a "main" (setup.nsi) file with the order of my custom pages (I'm using MUI2 and InstallOptions) . In setup.nsi I include a .nsh file that have the Create/Leave functions for a Custom Page.

I want to create a macro that pops up a message box if any input text is empty (macro FORCE_NOT_EMPTY_TEXT). When I compile I get warnings because of the macro and the parameters of the macro are empty (void string):

3 warnings:
LangString "field" is not set in language table of language English
LangString "dialog" is not set in language table of language English
LangString "message" is not set in language table of language English
Any suggestions?

thank you in advance


Macro:

!macro FORCE_NOT_EMPTY_TEXT dialog field message
    !insertmacro INSTALLOPTIONS_READ $0 $(dialog) $(field) "State"
    ${if} $0 == ""  
        MessageBox MB_ICONEXCLAMATION|MB_OK $(message) IDOK
        abort
    ${endif}
!macroend 
SETUP.NSI file:

# Included files
!include Sections.nsh
!include MUI2.nsh
!include InstallOptions.nsh
!include DialogIMAPConfiguration.nsh ; <<<<< include custom dialog implementation
!include DialogIMAPFolders.nsh
!include DialogSMTP.nsh
# Reserved Files
ReserveFile "${NSISDIR}\Plugins\System.dll"
# Variables
Var StartMenuGroup
# Installer pages
!insertmacro MUI_PAGE_WELCOME
Page custom CreateDialogIMAPConfiguration LeaveDialogIMAPConfiguration  ; <<<< my custom page
Page custom CreateDialogIMAPFolders
Page custom CreateDialogSMTP
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# Installer languages
!insertmacro MUI_LANGUAGE "English" ; <<<<<<<<<  language definition 
Custom Page "implementation": $(DIALOG_IMAP) and $(TXT_LOGIN_DIFFERENT) are LangString

Function CreateDialogIMAPConfiguration
  !insertmacro MUI_HEADER_TEXT $(PAGE_TITLE) $(PAGE_SUBTITLE)
  !insertmacro INSTALLOPTIONS_DISPLAY $(DIALOG_IMAP)
FunctionEnd
Function LeaveDialogIMAPConfiguration
        
    !insertmacro INSTALLOPTIONS_READ $0 $(DIALOG_IMAP) "Settings" "State"
    ${if} $0 == 0 ; LOGICA DE VALIDACION
        !insertmacro INSTALLOPTIONS_READ $0 $(DIALOG_IMAP) $(CHK_LOGIN_DIFFERENT) "State"
        ${if} $0 == 1  
            
            !insertmacro FORCE_NOT_EMPTY_TEXT  $(DIALOG_IMAP)  $(TXT_LOGIN_DIFFERENT) "Different login needed."       ; <<<<<<<< using the macro...
        ${endif}    
        
    ${else}   
    
        !insertmacro INSTALLOPTIONS_READ $0 $(DIALOG_IMAP) $(CHK_LOGIN_DIFFERENT) "State"
        ${if} $0 == 1
            !insertmacro INSTALLOPTIONS_READ $0 $(DIALOG_IMAP) $(TXT_LOGIN_DIFFERENT) "HWND"
             EnableWindow $0 1       
        ${else}
              !insertmacro INSTALLOPTIONS_READ $0 $(DIALOG_IMAP) $(TXT_LOGIN_DIFFERENT) "HWND"
               EnableWindow $0 0
        ${endif}
   
        abort
    ${endif}  
    
 
FunctionEnd 
Animaether#
You are using LangStrings ( in parentheses ) where I think you're looking for defines (in curly braces )

!macro FORCE_NOT_EMPTY_TEXT dialog field message
    !insertmacro INSTALLOPTIONS_READ $0 ${dialog} ${field} "State"
    ${if} $0 == ""  
        MessageBox MB_ICONEXCLAMATION|MB_OK ${message} IDOK
        abort
    ${endif}
!macroend 
USERDPRO#
Now I am using !defines instead of LangStrings to avoid the language table check and works fine. Thank you Animaether.