Search code examples
textboxnsismodern-ui

NSIS : Why "Text" from text box value became numeric?


I've created a custom page(.nsh) and there are 3 text boxes (url, user, password) for user typing in it and .NSI file will get these data to write into a properties file.

But those text became to numeric such 9502966, 4718976 and 8455398. What should I do?

This is my example code:

AcustomPage.nsh

...

!macro create_AcustomPage APP_NAME CUS_URL CUS_USER CUS_PWD
Page custom create_AcustomPage
Function create_AcustomPage
   ...
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_URL}"
   Pop $AcustomPage.url
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_USER}"
   Pop $AcustomPage.user
   ${NSD_CreateText} 60u 50u 60% 11u "${CUS_PWD}"
   Pop $AcustomPage.pwd
   ...
FunctionEnd
...
!macroend

Project.nsi

...

 !insertmacro create_AcustomPage "${NAME} ${VERSION}-${RELEASE}" "url.localhost" "username" "password"
...    
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_url=" "$CUS_URL" $R0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_user=" "$CUS_USER" $R0
${ConfigWriteS} "$INSTDIR\configure.properties" "custom_password=" "$CUS_PWD" $R0

Result #configure.properties

addi_url=18940788
addi_user=6750598
addi_password=11469950

But it should be:

addi_url=usl.localhost
addi_user=username
addi_password=password

Thanks,


Solution

  • I'm guessing you are writing the controls handle to the file but it is impossible to know because of your poor example code.

    It should probably look something like this:

    InstallDir "$Temp\Test"
    
    !include TextFunc.nsh
    !include nsDialogs.nsh
    
    
    var hCtlUrl
    var hCtlUsr
    var hCtlPwd
    
    !define DefaultUrl "url.localhost"
    !define DefaultUsr "foo"
    !define DefaultPwd "bar"
    
    Function mypageCreate
    nsDialogs::Create 1018
    Pop $0
    ${NSD_CreateText} 60u 30u 60% 11u "${DefaultUrl}"
    Pop $hCtlUrl
    ${NSD_CreateText} 60u 50u 60% 11u "${DefaultUsr}"
    Pop $hCtlUsr
    ${NSD_CreateText} 60u 70u 60% 11u "${DefaultPwd}"
    Pop $hCtlPwd
    nsDialogs::Show
    FunctionEnd
    
    Function mypageLeave
    ${NSD_GetText} $hCtlUrl $0
    ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_url=" "$0" $R0
    ${NSD_GetText} $hCtlUsr $0
    ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_user=" "$0" $R0
    ${NSD_GetText} $hCtlPwd $0
    ${ConfigWriteS} "$INSTDIR\configure.properties" "custom_password=" "$0" $R0
    FunctionEnd
    
    Page Directory
    Page InstFiles
    Page Custom mypageCreate mypageLeave