![]() |
How to pull all lines of a text file into a drop down
How to pull lines of text into a dropdown and select that in an NSIS install?
I am building an application installation that needs to pull a list of SQL Servers from the network. I have figured out how to do it with a vb script but I am now looking for a way to take the text file created by my VB script that lists the servers on their network. What I have done so far...
// START DBConnection_Script.nsi !define VERSIONNUMBER "version1.0.0.0" !define APPNAME "Choose Database" !define APPNAMEANDVERSION "Database Connection" Name "DB Config Test" OutFile "Database_Setup.exe" InstallDir "$TEMP\BLAH" ShowInstDetails show Var List !include "XPUI.nsh" Function .oninit !insertmacro XPUI_INSTALLOPTIONS_EXTRACT_AS "DBConnection.ini" "DBConnection.ini" FileOpen $4 "SVRList.txt" r FileSeek $4 0 ; we want to start reading at the 1000th byte FileRead $4 $1 ; we read until the end of line (including carriage return and new line) and save it to $1 FileRead $4 $2 30 ; read 30 characters from the next line StrCpy $List $2 ; add line two to the list variable FileClose $4 ; and close the file FunctionEnd ; XPUI Settings !define XPUI_ABORTWARNING ; Pages !insertmacro XPUI_PAGE_WELCOME Page custom "DB_Connection" "WriteDBReg" ;!insertmacro XPUI_PAGE_INSTFILES ;!insertmacro XPUI_PAGE_FINISH !insertmacro XPUI_LANGUAGE "English" Section "DatabaseUpdate" SEC01 SectionEnd Function DB_Connection !insertmacro XPUI_INSTALLOPTIONS_EXTRACT "DBConnection.ini" !insertmacro XPUI_INSTALLOPTIONS_WRITE "DBConnection.ini" "Field 6" "ListItems" "$List" !insertmacro XPUI_INSTALLOPTIONS_DISPLAY "DBConnection.ini" FunctionEnd Function WriteDBReg !insertmacro XPUI_INSTALLOPTIONS_READ $0 "DBConnection.ini" "Field 6" "ListItems" StrCpy $List "$0" WriteRegStr HKEY_LOCAL_MACHINE "Software\Application\General" "ServerList" "$List" FunctionEnd Section -Post SectionEnd // END DBConnection_Script.nsi // START DBConnection.ini script [Settings] NumFields=10 [Field 1] Type=Label Text=Database Connection: Left=5 Right=193 Top=3 Bottom=11 [Field 2] Type=Label Text=Please enter the server name where you have installed Microsoft SQL Server 2005. Left=9 Right=248 Top=22 Bottom=41 [Field 3] Type=Groupbox Text=SQL 2005 Connection Information Left=2 Right=250 Top=41 Bottom=160 [Field 4] Type=Checkbox Text= Use Microsoft Windows Domain/Active Directory authentication. Left=21 Right=239 Top=60 Bottom=70 [Field 5] Type=Label Text=Server(\\Instance): Left=10 Right=69 Top=78 Bottom=86 [Field 6] Type=Combobox Text=Combobox ListItems= Left=73 Right=240 Top=76 Bottom=89 [Field 7] Type=Label Text=Password: Left=33 Right=66 Top=99 Bottom=107 [Field 8] Type=Password Left=73 Right=240 Top=97 Bottom=110 [Field 9] Type=Label Text=Database Name: Left=12 Right=66 Top=121 Bottom=129 [Field 10] Type=Droplist Text=Droplist ListItems= Left=73 Right=240 Top=118 Bottom=155 // END DBConnection.ini script // START SVRList.txt (Local) ServerName1 ServerName2 ServerName3 ServerName4 // END SVRList.txt |
Do you want to read the selected list box item?
It's stored in the State field attribute. -Stu |
Thanks for taking the time to help...
Thanks for taking the time to respond. The code above opens the sqllist.txt file(which normally would have been created by the vb script) and then looks at line two, sets the list var to what was on line two and inserts the field into the dropdown - which works;however, what I am hoping to glean from the group is how to concatinate all the lines into the dropdown and allow the user to select only one, then run a check to connect and populate another list file of all the databases on that server.
Also: I'll provide all my vb scripts later in a zip file for everyone when I get everything working. For now I am just trying to keep things as simple as possible. |
Loop through the lines in the file, trimming each line and concatenate each line with StrCpy...
StrCpy $List $List|$R0 -Stu |
| All times are GMT. The time now is 04:29. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.