Urgent: Populate combobox with values from text file - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

toretwen
Posts: 1
Joined: Wed Apr 10, 2013 11:26 am

Urgent: Populate combobox with values from text file

Dear friends,

I am using the following details for populating the combox, but unfortunately it is not working, the result is combox is blank:

VBSCRIPT:

Code: Select all

Function PopulateComboWithOffices()
	Dim fso, strLine, pos, idx,srcFile
	Const comboProp = "CBOX_OFFICE"
	Const ForReading = 1
	Const orderStart = 10
	Const orderDelta = 5
	Const SEP_1 = "#"
	Const SEP_2 = "|"
	tempOfficeFile = Session.Property("TempFolder") & "OfficeList.txt" 'Session.Property("AI_OFFICELIST")
	'AI_OFFICELIST
	
	
	'Read the text file and populate the combo-box
	Set fso = CreateObject("Scripting.FileSystemObject") 
	Set srcFile  = fso.OpenTextFile(tempOfficeFile, ForReading, False)
	AIComboData = comboProp & SEP_1 & CStr(orderStart) & SEP_1 & CStr(orderDelta)
	idx = -1
	
	Do While srcFile.AtEndOfStream <> True
		idx = idx + 1
		strLine = srcFile.ReadLine
		pos = InStr(strLine, ",")
		strOfficeName = Left(strLine, pos-1)
		strOfficeID = Mid(strLine, pos)
		
		' the whole line will be inserted as value and the env. var. name as text
		AIComboData = AIComboData & SEP_2 & strOfficeID & SEP_1 & strOfficeName
		
		If idx = 0 Then
		  ' select the first item (index 0) in the ComboBox
		  Session.Property(comboProp) = strOfficeID
		End If    
	Loop
  
	' Close the file
	srcFile.Close
	
	' Set the Property that will be used as input by the AI PopulateComboBox
	' Custom Action
	Session.Property("AI_COMBOBOX_DATA") = AIComboData
	
End Function
In the Dialogs section, under Init Events:
Event: DoAction
Arguments: PopulateComboWithOffices
Condition: 1 AND AI_COMBOBOX_DATA <> "SUCCESS"

Kindly let me know how to populate the combox box dynamically from the text file, a step by step process will be nicer, so as to get it work quickly.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Urgent: Populate combobox with values from text file

Hello and welcome to Advanced Installer forums,

Thank you for your interest in Advanced Installer.

Please take a look on our "Dynamically Populate ComboBox via VBS" thread which should be useful for you.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”