Daemante2018 Posted November 28, 2018 Share Posted November 28, 2018 (edited) The code below has a button (Go!) which, depending on the choice made in the combobox, is meant to retrieve the data from the corresponding TXT file. It does work for "Option1", but, not "Option2". What am I doing wrong in the case section? expandcollapse popup#include <Array.au3> #include <File.au3> #include <GUIConstants.au3> #include <GuiListBox.au3> #include <ListBoxConstants.au3> $TestGUI = GUICreate("", 343, 611, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_SIZEBOX, $WS_THICKFRAME), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) GUISetFont(12, 400, 0, "MS Sans Serif") GUISetBkColor(0xFFFFFF) $SELECTOPTION = GUICtrlCreateCombo("Select Option", 8, 16, 121, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Option1|Option2") GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $OPTIONLIST = GUICtrlCreateList("", 8, 64, 325, 524, BitOR($LBS_NOSEL, $WS_VSCROLL)) $FILLOPTIONDATA = GUICtrlCreateButton("Go!", 248, 32, 75, 25) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FILLOPTIONDATA Select Case GUICtrlRead($SELECTOPTION) If GUICtrlRead($SELECTOPTION) = "Option1" Then GUICtrlSetData($OPTIONLIST, "") _CallOption1() EndIf Case GUICtrlRead($SELECTOPTION) If GUICtrlRead($SELECTOPTION) = "Option2" Then GUICtrlSetData($OPTIONLIST, "") _CallOption2() EndIf EndSelect EndSwitch WEnd Func _CallOption1() Local $aFileList _FileReadToArray("option1.txt", $aFileList) For $i = 1 To $aFileList[0] _GUICtrlListBox_AddString($OPTIONLIST, $aFileList[$i]) Next EndFunc ;==>_CallOption1 Func _CallOption2() Local $aFileList _FileReadToArray("option2.txt", $aFileList) For $i = 1 To $aFileList[0] _GUICtrlListBox_AddString($OPTIONLIST, $aFileList[$i]) Next EndFunc ;==>_CallOption2 option2.txt option1.txt TestCombo.au3 Edited November 28, 2018 by Daemante2018 Link to comment Share on other sites More sharing options...
TheXman Posted November 28, 2018 Share Posted November 28, 2018 (edited) The CASE clauses of the SELECT statement expect an expression that evaluates to a boolean value. You were close. I think the snippet below should help you move forward. The SELECT statement and the SWITCH statement are similar but their CASE clauses expect different values. You appeared to have been trying to use the SELECT as if it was a SWITCH statement. The HELP file is you friend. Pay more attention to the examples in the HELP file. https://www.autoitscript.com/autoit3/docs/keywords/Select.htm While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FILLOPTIONDATA Select Case GUICtrlRead($SELECTOPTION) = "Option1" GUICtrlSetData($OPTIONLIST, "") _CallOption1() Case GUICtrlRead($SELECTOPTION) = "Option2" GUICtrlSetData($OPTIONLIST, "") _CallOption2() EndSelect EndSwitch WEnd Edited November 28, 2018 by TheXman Daemante2018 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Daemante2018 Posted November 28, 2018 Author Share Posted November 28, 2018 I actually did read the help file and was mucking around but i had the Case statement a bit wrong apparently so I continued to muck around and ended up with the code I posted. Your code worked perfectly. You are the man @TheXman. Thanks! 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