mdcastle Posted May 16, 2012 Share Posted May 16, 2012 (edited) Please could someone help! I'm creating a GUI Script that allows a user to match a drop-down list of address fields to the corresponding field in a system I manage (see sample script below). The problem is that some of the options in the drop-down list may be blank. When the script creates the drop-down lists in the GUI, if the variable is blank that option and the one above do not show. As soon as I declare some text in the variable the GUI shows the options correctly expandcollapse popup#include <GUIconstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Opt("GUIcoordMode", 2) ;**************************************************************************************** ;* The 5 lines below will not form part of final script * ;* $rAddress1, 2, 3, 4, $rPostCode will be populated by cells from an Excel spreadsheet * ;**************************************************************************************** Global $rAddress1 = "1 Some Street" Global $rAddress2 = "" ; <----- If some text between the quotes here, the GUI Shows the drop-down options correctly. Global $rAddress3 = "ATown" Global $rAddress4 = "ACounty" Global $rPostCode = "AA1 1AA" Global $add1 = $rAddress1 Global $add2 = $rAddress2 Global $add3 = $rAddress3 Global $add4 = $rAddress4 Global $pc = $rPostCode Global $array[5] $array[0] = $add1 $array[1] = $add2 $array[2] = $add3 $array[3] = $add4 $array[4] = $pc GUICreate("Address Selecter", 280, 230) GUIStartGroup() Global $widthCell = 125 ; Address 1 option GUICtrlCreateLabel("Marketplace Address 1", 10, 10, $widthCell) Global $sAddress1 = GUICtrlCreateCombo("", 0, -1) For $i=0 to ubound($array) -1 GUICtrlSetData(-1, $array[$i]) NEXT ; Address 2 option GUICtrlCreateLabel("Marketplace Address 2", -2 * $widthCell, 10) Global $sAddress2 = GUICtrlCreateCombo("", 0, -1) For $i=0 to ubound($array) -1 GUICtrlSetData(-1, $array[$i]) NEXT ; City option GUICtrlCreateLabel("Marketplace City", -2 * $widthCell, 10) Global $sCity = GUICtrlCreateCombo("", 0, -1) For $i=0 to ubound($array) -1 GUICtrlSetData(-1, $array[$i]) NEXT ; County option GUICtrlCreateLabel("Marketplace County", -2 * $widthCell, 10) Global $sCounty = GUICtrlCreateCombo("", 0, -1) For $i=0 to ubound($array) -1 GUICtrlSetData(-1, $array[$i]) NEXT ; Post Code option GUICtrlCreateLabel("Marketplace Post Code", -2 * $widthCell, 10) Global $sPostCode = GUICtrlCreateCombo("", 0, -1) For $i=0 to ubound($array) -1 GUICtrlSetData(-1, $array[$i], $array[4]) NEXT Global $button_1 = GUICtrlCreateButton ("Ok", -1, 20, 120, 35) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE SplashTextOn("Exiting", "Exiting the script. Please re-run", 190, 100, -1, -1, 4, "", -1, 1000) Sleep(1500) SplashOff() Exit Case $msg = $button_1 ExitLoop EndSelect WEnd msgbox(0, "Selected Address", "Address1: " & GUICtrlRead($sAddress1) & " | Address2: " & GUICtrlRead($sAddress2) & " | City: " & GUICtrlRead($sCity) & " | County: " & GUICtrlRead($sCounty) & " | Post Code: " & GUICtrlRead($sPostCode)) GUIDelete() Many thanks in advance. Edited May 16, 2012 by mdcastle Link to comment Share on other sites More sharing options...
water Posted May 16, 2012 Share Posted May 16, 2012 TryGlobal $rAddress2 = " " ; <----- If some text between the quotes here, the GUI Shows the drop-down options correctly. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 16, 2012 Moderators Share Posted May 16, 2012 mdcastle, What a complicated way to fill your combos! Anyway, if you want a blank element in your combo list, you need to fill it all in one go like this: expandcollapse popup#include <guiconstants.au3> #include <comboconstants.au3> #include <editconstants.au3> #include <windowsconstants.au3> Opt("GUIcoordMode", 2) ;**************************************************************************************** ;* The 5 lines below will not form part of final script * ;* $rAddress1, 2, 3, 4, $rPostCode will be populated by cells from an Excel spreadsheet * ;**************************************************************************************** Global $rAddress1 = "1 Some Street" Global $rAddress2 = "" ; <----- If some text between the quotes here, the GUI Shows the drop-down options correctly. Global $rAddress3 = "ATown" Global $rAddress4 = "ACounty" Global $rPostCode = "AA1 1AA" Global $add1 = $rAddress1 Global $add2 = $rAddress2 Global $add3 = $rAddress3 Global $add4 = $rAddress4 Global $pc = $rPostCode Global $array[5] $array[0] = $add1 $array[1] = $add2 $array[2] = $add3 $array[3] = $add4 $array[4] = $pc ; Create a single string to fill the combo <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Global $sFullList = "" For $i = 0 To UBound($array) - 1 $sFullList &= "|" & $array[$i] Next GUICreate("Address Selecter", 280, 230) GUIStartGroup() Global $widthCell = 125 ; Address 1 option GUICtrlCreateLabel("Marketplace Address 1", 10, 10, $widthCell) Global $sAddress1 = GUICtrlCreateCombo("", 0, -1) GUICtrlSetData(-1, $sFullList) ; And load it in a single operation ; <<<<<<<<<<<<<<<<<<<<<<<<<< ; Address 2 option GUICtrlCreateLabel("Marketplace Address 2", -2 * $widthCell, 10) Global $sAddress2 = GUICtrlCreateCombo("", 0, -1) GUICtrlSetData(-1, $sFullList); City option GUICtrlCreateLabel("Marketplace City", -2 * $widthCell, 10) Global $sCity = GUICtrlCreateCombo("", 0, -1) GUICtrlSetData(-1, $sFullList); County option GUICtrlCreateLabel("Marketplace County", -2 * $widthCell, 10) Global $sCounty = GUICtrlCreateCombo("", 0, -1) GUICtrlSetData(-1, $sFullList); Post Code option GUICtrlCreateLabel("Marketplace Post Code", -2 * $widthCell, 10) Global $sPostCode = GUICtrlCreateCombo("", 0, -1) GUICtrlSetData(-1, $sFullList) Global $button_1 = GUICtrlCreateButton("Ok", -1, 20, 120, 35) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE SplashTextOn("Exiting", "Exiting the script. Please re-run", 190, 100, -1, -1, 4, "", -1, 1000) Sleep(1500) SplashOff() Exit Case $msg = $button_1 ExitLoop EndSelect WEnd MsgBox(0, "Selected Address", "Address1: " & GUICtrlRead($sAddress1) & " | Address2: " & GUICtrlRead($sAddress2) & " | City: " & GUICtrlRead($sCity) & " | County: " & GUICtrlRead($sCounty) & " | Post Code: " & GUICtrlRead($sPostCode)) GUIDelete() Now you get yoru blank line. M23</windowsconstants.au3></editconstants.au3></comboconstants.au3></guiconstants.au3> Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mdcastle Posted May 16, 2012 Author Share Posted May 16, 2012 What a complicated way to fill your combos! I'm not surprised that i found the most complicated way to do this! I'm very much a beginner at all things scripting so please be gentle .Many thanks for your help. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now