prizm1 Posted September 23, 2014 Share Posted September 23, 2014 I notice that this function does not preserve the ending delimiter when returning the delimited string of all Combobox items. Or, Perhaps this is a result of the _GUICtrlComboBox_InsertString not preserving the ending delimiter. I'm not sure how to test which function does not preserve the closing delimiter. If I insert the string "|Car|Boat|Plane|Horse|" into the Combobox using _GUICtrlComboBox_InsertString , and then retrieve the string list using _GUICtrlComboBox_GetList, I get ""|Car|Boat|Plane|Horse" without the closing delimiter. Is this by design? Could someone explain the conceptual reason for this. Of course, I can just concatenate a closing "|" delimiter to the result from _GUICtrlComboBox_GetList. Source code Line 79 is where I encountered this question. Lifetime COG Tracking Application.au3 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2014 Moderators Share Posted September 23, 2014 prizm1,I am afraid I do not understand your problem. If you insert a string into a combo using _GUICtrlComboBox_InsertString it is regarded as a single item even if it contains delimiters - you can see this with Combo_1 in the example code below. Reading the combo content with _GUICtrlComboBox_GetList returns the same string - obviously with the ending delimiter as that is part of the item.If you add the string to the combo using GUICtrlSetData then it is treated as delimited and the items are added individually - as you can see with Combo_2. Note that the final delimiter is ignored - there is no blank item added at the bottom of the combo. So when the list is read with _GUICtrlComboBox_GetList you will not get a final delimiter - there is nothing to delimit. This is the example code I rant to test:#include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Combo 1", 10, 10, 200, 20) $cCombo_1 = GUICtrlCreateCombo("", 10, 30, 200, 20) _GUICtrlComboBox_InsertString($cCombo_1, "|Car|Boat|Plane|Horse|") GUICtrlCreateLabel("Combo 2", 260, 10, 200, 20) $cCombo_2 = GUICtrlCreateCombo("", 260, 30, 200, 20) GUICtrlSetData($cCombo_2, "|Car|Boat|Plane|Horse|") GUISetState() ConsoleWrite("Combo_1: " & _GUICtrlComboBox_GetList($cCombo_1) & @CRLF) ConsoleWrite("Combo_2: " & _GUICtrlComboBox_GetList($cCombo_2) & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndI suggest you try to create a simple reproducer script which shows the problem you say you have discovered as at present I cannot reproduce it in the manner you suggest. M23 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...
BrewManNH Posted September 23, 2014 Share Posted September 23, 2014 When you retrieve the contents of the combo with _GUICtrlComboBox_GetList it doesn't add the final delimiter by design, I'm pretty sure it's always been like that and for perfectly good reasons. The contents of the combo are added and separated by the delimiter,the extra delimiter at the end is automatically stripped when adding the items to the combo, otherwise you'd have a blank item at the end of your combo box. Adding it when you put the items in there won't preserve it when retrieving it, even if the function didn't strip it. You can look at the function _GUICtrlComboBox_GetList and see how the combo items are retrieved and the returned string is built up. It's simply reads each item in the combo, adds it to a string and then adds the delimiter. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Solution prizm1 Posted September 24, 2014 Author Solution Share Posted September 24, 2014 prizm1, I am afraid I do not understand your problem. If you insert a string into a combo using _GUICtrlComboBox_InsertString it is regarded as a single item even if it contains delimiters - you can see this with Combo_1 in the example code below. Reading the combo content with _GUICtrlComboBox_GetList returns the same string - obviously with the ending delimiter as that is part of the item. If you add the string to the combo using GUICtrlSetData then it is treated as delimited and the items are added individually - as you can see with Combo_2. Note that the final delimiter is ignored - there is no blank item added at the bottom of the combo. So when the list is read with _GUICtrlComboBox_GetList you will not get a final delimiter - there is nothing to delimit. This is the example code I rant to test: #include <GUIConstantsEx.au3> #include <GUIComboBox.au3> $hGUI = GUICreate("Test", 500, 500) GUICtrlCreateLabel("Combo 1", 10, 10, 200, 20) $cCombo_1 = GUICtrlCreateCombo("", 10, 30, 200, 20) _GUICtrlComboBox_InsertString($cCombo_1, "|Car|Boat|Plane|Horse|") GUICtrlCreateLabel("Combo 2", 260, 10, 200, 20) $cCombo_2 = GUICtrlCreateCombo("", 260, 30, 200, 20) GUICtrlSetData($cCombo_2, "|Car|Boat|Plane|Horse|") GUISetState() ConsoleWrite("Combo_1: " & _GUICtrlComboBox_GetList($cCombo_1) & @CRLF) ConsoleWrite("Combo_2: " & _GUICtrlComboBox_GetList($cCombo_2) & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I suggest you try to create a simple reproducer script which shows the problem you say you have discovered as at present I cannot reproduce it in the manner you suggest. M23 Thank you for your invaluable information. The program that I wrote utilized the _StringBetween() function to create an array from a fully delimited string, ex., "|<NOT USED>|Top Left [1]|Top Right [2]|Middle Left [1]|Middle Right [2]|". The fully delimited string was a single element text item in a two dimensional array imported from a CSV file using the _FileReadArray() funtion. CSV file line entry, ex., SKL HV BT 35;|<NOT USED>|Top Left [1]|Top Right [2]|Middle Left [1]|Middle Right [2]| The problem I had was that I did not understand that the GetCtrlSetData() function that I used to populate Comboboxes dropped the ending delimiter. The Help file did not detail this fact. So, when my error input checking function which incorporated the line $TxtSrchPos = StringInStr($SKLHVPOS, "|" & StringStripWS(GUICtrlRead($rPos), 3) & "|"), with $rPos being the pointer assigned variable to the combobox and $SKLHVPOS = "|<NOT USED>|Top Left [1]|Top Right [2]|Middle Left [1]|Middle Right [2]|", the last combox item was not found and $TxtSrchPos returned 0, I have since corrected my error input checking function line to $TxtSrchPos = StringInStr($SKLHVPOS, "|" & StringStripWS(GUICtrlRead($rPos), 3)) , and now the last combobox selected item is found by the StringInStr() function. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 24, 2014 Moderators Share Posted September 24, 2014 prizm1, I did not understand that the GetCtrlSetData() function [...] dropped the ending delimiter. The Help file did not detail this factIt does not "drop" the delimiter, it just does not create a blank final item if there is a trailing delimiter in the string - which is obvious when looking at the combo content. But I have added a suitable comment to the Help file to prevent any future confusion. M23 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...
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