timdecker Posted April 14, 2015 Share Posted April 14, 2015 Whenever I load a new file, my checkboxes are not changing. What do I need to do to make sure I have the correct number of checkboxes along with the correct name? Checkboxes = headers Code: expandcollapse popup#include <file.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <GuiListView.au3> #include <Array.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> Global $a_csv Global $listview Global $checkboxName Global $iCount Global $runProg Global $acheck Global $mapColumn Global $runProg Global $selectInstrument Global $selectFile Global $s_Path $s_Path = FileOpenDialog("Select CVS File", @ScriptDir, "comma seperated values (*.csv)") If @error Then MsgBox(4096, "", "No File(s) chosen") Exit Else _FileReadToArray($s_Path, $a_csv) buildGUI() EndIf Func _loadNewFile() _FileReadToArray(GUICtrlRead($selectFile),$a_csv) $listview = GUICtrlCreateListView(StringReplace($a_csv[1], ",", "|"), 10, 10, 400, 210) For $i = 2 To UBound($a_csv) - 1 $s_temp = StringReplace($a_csv[$i], ",", "|") GUICtrlCreateListViewItem($s_temp, $listview) Next EndFunc Func copyToInput() ;$title = "(METTLER) - TGA-200A with gas box" ;$title = "HPOV" Select Case GUICtrlRead($selectInstrument) = "dummy" $textPos = 4 $title = "HPOV" Case GUICtrlRead($selectInstrument) = "TGA-100" $textPos = 35 $title = "(METTLER) - TGA-100A with gas box" Case GUICtrlRead($selectInstrument) = "TGA-200" $textPos = 44 $title = "(METTLER) - TGA-200A with gas box" Case GUICtrlRead($selectInstrument) = "AUTOCAT-100" $textPos = 75 Case GUICtrlRead($selectInstrument) = "AUTOCAT-200" $textPos = 15 EndSelect $allRows = _GUICtrlListView_GetItemCount($listview) For $rows = 0 to $allRows-1 $material_name = _GUICtrlListView_GetItem($listview, $rows, 0) $letter = _GUICtrlListView_GetItem($listview, $rows, 3) If GUICtrlRead($aCheck[1]) <> 1 and GUICtrlRead($aCheck[4]) <> 1 then continueloop If GUICtrlRead($aCheck[1]) = 1 Then controlsettext($title, "", $textPos, $material_name[3]) endif #cs - 2nd input box If GUICtrlRead($aCheck[4]) = 1 Then controlsettext($title, "", 5, $letter[3]) endif #ce controlclick($title, "", 6) Sleep(2000) ;there you can put some sleep(5000) = 5seconds, more or less, if u know exact applications processing time for this operation ;or ControlGetText("Myapplication title", "", CONTROL_WHICH_CHANGES_AFTER_BUTTONPRESS) and compare to older reads controlclick("Job", "", 2) Sleep(2000) ;there you can put some sleep(5000) = 5seconds, more or less, if u know exact applications processing time for this operation ;or ControlGetText("Myapplication title", "", CONTROL_WHICH_CHANGES_AFTER_BUTTONPRESS) and compare to older reads if msgbox(1,"", "You Shall Not Pass!" & @CRLF & "Ok actually you can, just press something") = 2 then ExitLoop endif Next EndFunc Func buildGUI() GUICreate("CSV Listview", 900, 450, -1, -1) $listview = GUICtrlCreateListView(StringReplace($a_csv[1], ",", "|"), 10, 10, 400, 210) GUICtrlCreateLabel("Select a sample file:", 450, 40, 200) $selectFile = GUICtrlCreateCombo("", 450, 60, 180, 200) _GUICtrlComboBox_BeginUpdate($selectFile) _GUICtrlComboBox_AddDir($selectFile, @ScriptDir & "\*.csv") _GUICtrlComboBox_EndUpdate($selectFile) $loadNewFile = GUICtrlCreateButton("Load File", 450, 80) GUICtrlCreateLabel("Select an instrument:", 700, 40, 200) $selectInstrument = GUICtrlCreateCombo("", 700, 60, 180, 25) GUICtrlSetData(-1, "dummy|TGA-100|TGA-200|AUTOCAT-100|AUTOCAT-200") $checkboxName = StringSplit($a_csv[1], ",") $iCount = $checkboxName[0] ;creating buttons Global $aCheck[$iCount + 1] Global $mapColumn[$iCount + 1] ;$nextSample = GUICtrlCreateButton("Map sample submition button ", 395, 320, 180, 30) $runProg = GUICtrlCreateButton("Run Program", 700, 400, 180, 30) GUICtrlSetState($runProg, $GUI_DISABLE) ;$btnStop = GUICtrlCreateButton("Stop", 700, 400, 180, 30) For $j = 1 To $iCount ; Store controIDs of the checkboxes $aCheck[$j] = GUICtrlCreateCheckbox($checkboxName[$j], 10, 190 + (50 * $j), 100, 30) ; $mapColumn[$j] = GUICtrlCreateButton("Map " & '"' & $checkboxName[$j] & '"' & " to input box", 150, 190 + (50 * $j), 180, 30) GUICtrlSetState($aCheck[$j], $GUI_UNCHECKED) ; GUICtrlSetState($mapColumn[$j], $GUI_DISABLE) Next For $i = 2 To UBound($a_csv) - 1 $s_temp = StringReplace($a_csv[$i], ",", "|") GUICtrlCreateListViewItem($s_temp, $listview) Next Global $aOut[''][''] For $i = 2 to $a_csv[0] $aLine = stringsplit($a_csv[$i] , ",",3) If ubound($aLine) > ubound($aOut , 2) Then redim $aOut[$i][ubound($aLine)] _ArrayAdd($aOut , $a_csv[$i] , 0 , ",") ; consolewrite("line: " & $aLine[2] & @LF) Next GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $runProg copyToInput() Case $loadNewFile _GUICtrlListView_DeleteAllItems($listview) _loadNewFile() Case Else For $i = 1 To $iCount If $msg = $aCheck[$i] Then If GUICtrlRead($msg) = 1 Then ; GUICtrlSetState($mapColumn[$i], $GUI_ENABLE) GUICtrlSetState($runProg, $GUI_ENABLE) ; ; Local $text = "" ; For $k = 0 to $a_csv[0]-1 ; $text &= ControlListView ("CSV Listview", "", $listview, "GetText", $k, $i-1) & @crlf ; ; Next ;Msgbox(0,$checkboxName[$i], $text) ; debug, can see the list of samples you selected Else ;GUICtrlSetState($mapColumn[$i], $GUI_DISABLE) GUICtrlSetState($runProg, $GUI_DISABLE) EndIf ExitLoop EndIf Next EndSwitch WEnd EndFunc Sample CSV1: Building,Room,Network Building1,Room1,Network_Path1 Building2,Room2,Network_Path2 Building3,Room3,Network_Path3 Building4,Room4,Network_Path4 Building5,Room5,Network_Path5 Sample CSV2: material_name,material_alias,period,letter HT-000001331,,r1,A1 HT-000001330,alias 3 not 4,r2,A2 dummy,,,A3 RS-000001336,,r4,A4 HT-000001335,,r2,A5 dummy,,,A6 HT-000001334,,r2,A7 HT-000001328,alias1,r1,A8 HT-000001333,,r2,B1 dummy,,,B2 dummy,,,B3 HT-000001332,,r1,B4 dummy,,,B5 HT-000001332,,r2,B6 HT-000001329,alias 2,r2,B7 dummy,,,B8 dummy,,,C1 dummy,,,C2 Thanks for the 50 some odd time guys! Tim Link to comment Share on other sites More sharing options...
timdecker Posted April 15, 2015 Author Share Posted April 15, 2015 My morning bump.... Mods, move this to another section if this is not the best place for this post. Thanks! Tim 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