user1717161
user1717161

Reputation: 11

Extra newline characters between items in a drop down menu

I am creating a installer using the nsis installer. In that installer I need to put a drop down menu for currency selection.

The text file which I am using is not being properly inserted, the newline character that I am using to separate the currencies is actually taking a character in the installer, while for the license page I am using the same extension for the text file which I am putting there and it is working fine over there.

How to filter out those extra characters?

Upvotes: 1

Views: 517

Answers (1)

Anders
Anders

Reputation: 101666

Without a sample file I had to guess what the actual problem is, hopefully its just the newlines:

Page custom mycustompage

!include nsDialogs.nsh
!include TextFunc.nsh

Function mycustompage
nsDialogs::Create 1018
Pop $0

; I don't have a list of things so I generate one on the fly for this example:
!tempfile MYLIST
!appendfile "${MYLIST}" "Foo$\r"
!appendfile "${MYLIST}" "Bar$\r$\n"
!appendfile "${MYLIST}" "Baz$\n"
File "/oname=$pluginsdir\thelist.txt" "${MYLIST}" ; include list in installer
!delfile "${MYLIST}"

${NSD_CreateDropList} 10u 10u 50% 100% ""
Pop $0

FileOpen $1 "$pluginsdir\thelist.txt" r
loop:
    FileRead $1 $2
    IfErrors endloop
    ${TrimNewLines} $2 $2
    StrCmp $2 "" loop ; skip empty line
    ${NSD_CB_AddString} $0 $2
    goto loop
endloop:

nsDialogs::Show
FunctionEnd

Upvotes: 1

Related Questions