Skip to content
⌘ NSIS Forum Archive

Error in the script, but why?

2 posts

ghola2#

Error in the script, but why?

Hy!

I am trying to make a custom page, who has 2 textboxes, and init these textboxes with values from in.ini file if exist. The problem is that in the function where should be the init, i can't even make a strcpy, because it throws an error, that i am not using the correct sintax... (same problem with MUI_INSTALLOPTIONS_READ, or ReadINIStr, Pop )
What I am doing wrong? Can anybody help me?

Thanks in advance


;--------------------------------
;Include Modern UI
  !include "MUI.nsh"
    !include "TextFunc.nsh"
    
    ReserveFile "ServerPort.ini"
  !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
;--------------------------------
;General
  ;Name and file
  Name "Modern UI Test"
  OutFile "Basic.exe"
  ;Default installation folder
  InstallDir "$PROGRAMFILES\Modern UI Test"
  
  ;Get installation folder from registry if available
  InstallDirRegKey HKCU "Software\Modern UI Test" ""
;--------------------------------
;Interface Settings
  !define MUI_ABORTWARNING
;--------------------------------
;Pages
   
     !insertmacro MUI_PAGE_WELCOME
     
  
  !insertmacro MUI_PAGE_COMPONENTS
  !insertmacro MUI_PAGE_DIRECTORY
      Page custom ServerPage
  !insertmacro MUI_PAGE_INSTFILES
 
    
  !insertmacro MUI_UNPAGE_CONFIRM
  !insertmacro MUI_UNPAGE_INSTFILES
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
Section "Dummy Section" SecDummy
  SetOutPath "$INSTDIR"
  
  ;ADD YOUR OWN FILES HERE...
  
  ;Store installation folder
  WriteRegStr HKCU "Software\Modern UI Test" "" $INSTDIR
  
  ;Create uninstaller
  WriteUninstaller "$INSTDIR\Uninstall.exe"
SectionEnd
;--------------------------------
;Descriptions
  ;Language strings
    LangString USERPASS_TITLE ${LANG_ENGLISH} "Enter your Username and Password."
    LangString USERPASS_SUBTITLE ${LANG_ENGLISH} " "
  LangString DESC_SecDummy ${LANG_ENGLISH} "A test section."
  ;Assign language strings to sections
  !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
    !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
  !insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
;Uninstaller Section
Section "Uninstall"
  ;ADD YOUR OWN FILES HERE...
  Delete "$INSTDIR\Uninstall.exe"
  RMDir "$INSTDIR"
  DeleteRegKey /ifempty HKCU "Software\Modern UI Test"
SectionEnd
Function .OnInit
!insertmacro MUI_INSTALLOPTIONS_EXTRACT_AS "ServerPort.ini" "ServerPort.ini"
FunctionEnd
# CUSTOM PAGE.
# =========================================================================
# Get the Username and Password.
Function ServerPage
   !insertmacro MUI_HEADER_TEXT "$(USERPASS_TITLE)" "$(USERPASS_SUBTITLE)"
  
;ReadINIStr $serverPort "$INSTDIR\in.ini" "Server" "Port" ; generates error, why?!
;StrCpy $R99 "semmi kozod!!!!" ;GENERATES ERROR WHY?!
     
     
    
     !insertmacro MUI_INSTALLOPTIONS_WRITE  "ServerPort.ini" "Field 2" "State" "alma";"$serverName"
     !insertmacro MUI_INSTALLOPTIONS_WRITE  "ServerPort.ini" "Field 4" "State" "12";"$serverPort"
   # Display the page.
   !insertmacro MUI_INSTALLOPTIONS_DISPLAY "ServerPort.ini"
   # Get the user entered values.
    
    !insertmacro MUI_INSTALLOPTIONS_READ $R0 "ServerPort.ini" "Field 2" "State"
  !insertmacro MUI_INSTALLOPTIONS_READ $R1 "ServerPort.ini" "Field 4" "State"
    
    
MessageBox MB_OK "{$R0}+ $R1" 
FunctionEnd 
Afrow UK#
You need to declare variables with the Var instruction.
Variables $0-$9 and $R0 to $R9 are predeclared by the compiler.

e.g.
Var serverPort

-Stu