E1M1 Posted March 5, 2011 Share Posted March 5, 2011 (edited) If you click remove buttons in order 1,2,3,4 everything gets removed as needed. But when you click buttons in order 3,4 then then first and second button doesn't work anymore.Idea of program:Generate window controls dynamically and then allow user user to remove them by clicking remove button.Picture explains what I meant with order 1 2 3 4.Does anyone have any ideas what might help me?Code to look at is located between lines 97 and 133 (in for loop). Other code is fine I just cant find whats wrong there .expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> ;write 2 files to disk timeedit() timing() ;read files from disk $list = False If FileExists(@ScriptDir & "\timeedit.eng.lng") Then $list = StringSplit(FileRead(@ScriptDir & "\timeedit.eng.lng"), @CRLF, 1) EndIf $sFileData = FileRead(@ScriptDir & "\timing.lua") Dim $buttons[1] $buttons[0] = "-9999" Dim $OtherControls[1][4] $iTab = 1 $y = 50 $TYPE_HANDLE = 0 $TYPE_TYPE = 1 $TYPE_LINE = 2 $TYPE_TAB = 3 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Timing", 628, 453, 192, 124) If $list[0] > 1 Then WinSetTitle($Form1, "", $list[10]) $Tab1 = GUICtrlCreateTab(0, 0, 625, 417) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Mon") If $list[0] > 1 Then GUICtrlSetData(-1, $list[1]) _execute(GetTiming("Monday")) $TabSheet2 = GUICtrlCreateTabItem("Tue") If $list[0] > 1 Then GUICtrlSetData(-1, $list[2]) $y = 50 ;~ _execute(GetTiming("Tuesday")) $TabSheet3 = GUICtrlCreateTabItem("Wed") If $list[0] > 1 Then GUICtrlSetData(-1, $list[3]) $y = 50 ;~ _execute(GetTiming("Wednesday")) $TabSheet4 = GUICtrlCreateTabItem("Thu") If $list[0] > 1 Then GUICtrlSetData(-1, $list[4]) $y = 50 ;~ _execute(GetTiming("Thursday")) $TabSheet5 = GUICtrlCreateTabItem("Fri") If $list[0] > 1 Then GUICtrlSetData(-1, $list[5]) $y = 50 ;~ _execute(GetTiming("Friday")) $TabSheet6 = GUICtrlCreateTabItem("Sat") If $list[0] > 1 Then GUICtrlSetData(-1, $list[6]) $y = 50 ;~ _execute(GetTiming("Saturday")) $TabSheet7 = GUICtrlCreateTabItem("Sun") If $list[0] > 1 Then GUICtrlSetData(-1, $list[7]) $y = 50 ;~ _execute(GetTiming("Sunday")) GUICtrlCreateTabItem("") $Save = GUICtrlCreateButton("Save", 8, 424, 75, 25, $WS_GROUP) If $list[0] > 1 Then GUICtrlSetData(-1, $list[8]) $Reload = GUICtrlCreateButton("Reload", 88, 424, 75, 25, $WS_GROUP) If $list[0] > 1 Then GUICtrlSetData(-1, $list[9]) $new = GUICtrlCreateButton($list[16], 548, 424, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) Func _execute($sStr) Local $handle Local $iLine = 1 $a = StringSplit($sStr, @CRLF, 1) For $i = 1 To $a[0] $handle = Execute($a[$i]) If StringInStr($a[$i], "GUICtrlCreateCombo") Or StringInStr($a[$i], "GUICtrlCreateInput") Or StringInStr($a[$i], "GUICtrlCreateButton") Then ReDim $OtherControls[UBound($OtherControls) + 1][4] $OtherControls[UBound($OtherControls) - 1][0] = $handle $OtherControls[UBound($OtherControls) - 1][1] = CtrlGetType_S($a[$i]) $OtherControls[UBound($OtherControls) - 1][2] = $iLine $OtherControls[UBound($OtherControls) - 1][3] = $iTab If CtrlGetType_S($a[$i]) = 2 Then $iLine += 1 EndIf Next $iTab += 1 EndFunc ;==>_execute Func CtrlGetType_S($sStr) If StringInStr($sStr, "GUICtrlCreateCombo") Then Return 0 EndIf If StringInStr($sStr, "GUICtrlCreateInput") Then Return 1 EndIf If StringInStr($sStr, "GUICtrlCreateButton") Then Return 2 EndIf EndFunc ;==>CtrlGetType_S #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() For $i = 0 To UBound($OtherControls, 1) - 1 If $nMsg = $OtherControls[$i][0] Then If $OtherControls[$i][1] = 2 Then $TabItems = ArrayGetByProperty($OtherControls, $TYPE_TAB, $OtherControls[$i][3]) $LineItems = ArrayGetByProperty($TabItems, $TYPE_LINE, $OtherControls[$i][2]) $OtherControls[$i][1] = 0 ; make it other than button so loop below would remove it Local $iCount = 0 ;Increase this to use it later For $n = $i To 0 Step -1 If $OtherControls[$n][1] = 2 Or $n = 0 Then ;if we reached to previous remove button or beginning of array ExitLoop EndIf $iCount += 1 GUICtrlDelete($OtherControls[$n][0]) Next $RealCount = 0 If $n = 0 Then $n = 1 Dim $sNewArray[UBound($OtherControls, 1) - $iCount][4] $line = 1 For $ArrayItems = 1 To UBound($sNewArray, 1) - 1 $RealCount += 1 If $RealCount = $n Then $RealCount += $iCount;use count to deleted controls from array EndIf ConsoleWrite($ArrayItems& " "&$RealCount&@CRLF) $sNewArray[$ArrayItems][0] = $OtherControls[$RealCount][0] $sNewArray[$ArrayItems][1] = $OtherControls[$RealCount][1] $sNewArray[$ArrayItems][2] = $line $sNewArray[$ArrayItems][3] = $OtherControls[$RealCount][3] If CtrlGetType_S($sNewArray[$ArrayItems][1]) = 2 Then $Line += 1; CtrlGetType_S returns 2 for button Next ConsoleWrite("Line: " & $OtherControls[$i][2] & " Tab: " & $OtherControls[$i][3] & @CRLF) $OtherControls = $sNewArray ExitLoop EndIf EndIf Next Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save EndSwitch WEnd Func ArrayGetByProperty($aArray, $iProperty, $val) Dim $aNewArray[1][4] For $i = 0 To UBound($aArray, 1) - 1 If $aArray[$i][$iProperty] = $val Then ReDim $aNewArray[UBound($aNewArray, 1) + 1][4] $aNewArray[UBound($aNewArray, 1) - 1][0] = $aArray[$i][0] $aNewArray[UBound($aNewArray, 1) - 1][1] = $aArray[$i][1] $aNewArray[UBound($aNewArray, 1) - 1][2] = $aArray[$i][2] $aNewArray[UBound($aNewArray, 1) - 1][3] = $aArray[$i][3] EndIf Next Return $aNewArray EndFunc ;==>ArrayGetByProperty Func GetTiming($sDay) $split = StringSplit($sFileData, @CRLF, 1) For $i = 1 To $split[0] $start = StringInStr($split[$i], "function " & $sDay) If $start Then ExitLoop EndIf Next ;~ ConsoleWrite("i = " & $i & @CRLF) For $n = $i To $split[0] $start = StringInStr($split[$n], "Allowed =") If $start Then ExitLoop EndIf Next ;~ ConsoleWrite("n = " & $n & @CRLF) For $a = $n To $split[0] $paramstart = StringInStr($split[$a], "(") If $paramstart Then ExitLoop EndIf Next ;~ ConsoleWrite("a = " & $a & @CRLF) For $b = $a To $split[0] $paramend = StringInStr($split[$b], ")") If $paramend Then ExitLoop EndIf Next ;~ ConsoleWrite("b = " & $b & @CRLF) $fullstr = "" For $c = $a To $b $fullstr &= Interpretate(_RemoveSpace($split[$c])) Next Return $fullstr EndFunc ;==>GetTiming Func Interpretate($sStr) If StringLeft($sStr, 2) = "--" Then Return "" EndIf If StringLen($sStr) < 2 Then Return "" EndIf $words = StringSplit($sStr, " ") $global = "" If $words[0] >= 3 Then For $i = 1 To $words[0] If StringInStr($words[$i], "<") Or StringInStr($words[$i], ">") Or StringInStr($words[$i], "=") Then $data = '' $data &= 'GUICtrlCreateCombo("", ' & 10 + ($i - 1) * 120 & ', ' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"<|>|==|<=|>=|~="') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0xff0000)' & @CRLF EndIf If StringInStr($words[$i], "and") Or StringInStr($words[$i], "or") Then $data = '' $data &= 'GUICtrlCreateCombo("",' & 10 + ($i - 1) * 120 & ',' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"and|or"') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0x0000ff)' & @CRLF EndIf If StringInStr($words[$i], "minute") Or StringInStr($words[$i], "hour") Then $data = '' $data &= 'GUICtrlCreateCombo("", ' & 10 + ($i - 1) * 120 & ',' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"hour|minute"') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0xcc00cc)' & @CRLF EndIf If StringIsDigit($words[$i]) Then $data = '' $data &= 'GUICtrlCreateInput("' & luaReplace($words[$i]) & '",' & 10 + ($i - 1) * 120 & ',' & $y & ',75,25)' & @CRLF EndIf $global &= $data ;~ ConsoleWrite($words[$i]&@CRLF) Next EndIf $global &= 'GUICtrlCreateButton("' & $list[15] & '",' & 10 + ($i - 1) * 120 & ',' & $y & ',75,25)' & @CRLF $y += 45 Return $global EndFunc ;==>Interpretate Func luaReplace($sStr) $sStr = StringReplace($sStr, "hour", $list[11]) $sStr = StringReplace($sStr, "minute", $list[12]) $sStr = StringReplace($sStr, "and", $list[13]) $sStr = StringReplace($sStr, "or", $list[14]) Return $sStr EndFunc ;==>luaReplace ; #FUNCTION# ;=============================================================================== ; ; Name...........: _RemoveSpace ; Description ...: Removes spaces and tabs at beginning of string ; Syntax.........: _RemoveSpace($sString) ; Parameters ....: $sString - Input string ; Return values .: $sString with out spaces and tabs at the beginning of string ; Author ........: E1M1 ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; No ; ; ;========================================================================================== Func _RemoveSpace($sString) While 1 If StringLeft($sString, 1) = " " Or StringLeft($sString, 1) = @TAB Then $sString = StringTrimLeft($sString, 1) Else Return $sString EndIf WEnd EndFunc ;==>_RemoveSpace Func timeedit() FileDelete(@ScriptDir&"\timeedit.eng.lng") FileWrite(@ScriptDir&"\timeedit.eng.lng",BinaryToString("0x4D6F6E6461790D0A547565736461790D0A5765646E65736461790D0A54687572736461790D0A4672696461790D0A53617475726461790D0A53756E6461790D0A536176650D0A52656C6F61640D0A54696D65730D0A686F75720D0A6D696E7574650D0A616E640D0A6F720D0A72656D6F76650D0A4164640D0A")) endfunc Func timing() FileDelete(@ScriptDir&"\timing.lua") FileWrite(@ScriptDir&"\timing.lua",BinaryToString("0x6E6F77203D206F732E6461746528222A7422293B206C6F63616C20686F75722C6D696E7574652C7765656B646179203D206E6F772E686F75722C6E6F772E6D696E7574652C6E6F772E776461793B0D0A7661726961626C65203D20313233340D0A66756E6374696F6E204973416C6C6F77656428290D0A096C6F63616C204669786564203D20747275650D0A096C6F63616C20416C6C6F776564203D2066616C73650D0A0D0A096966204669786564203D3D2066616C7365207468656E0D0A09096966207765656B646179203D3D2031207468656E20416C6C6F776564203D2053756E64617928290D0A0909656C73656966207765656B646179203D3D2032207468656E20416C6C6F776564203D20204D6F6E64617928290D0A0909656C73656966207765656B646179203D3D2033207468656E20416C6C6F776564203D20205475657364617928290D0A0909656C73656966207765656B646179203D3D2034207468656E20416C6C6F776564203D205765646E657364617928290D0A0909656C73656966207765656B646179203D3D2035207468656E20416C6C6F776564203D20546875727364617928290D0A0909656C73656966207765656B646179203D3D2036207468656E20416C6C6F776564203D2046726964617928290D0A0909656C73656966207765656B646179203D3D2037207468656E20416C6C6F776564203D20536174757264617928290D0A0909656E640D0A09656C73650D0A0909416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A09656E640D0A0D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E204D6F6E64617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E205475657364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E205765646E657364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E20546875727364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E2046726964617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E20536174757264617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E2053756E64617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E64")) endfunc Edited March 5, 2011 by E1M1 edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 E1M1,It looks as if you are incorrectly setting the line information in your array when you delete a line. Try adding some _ArrayDisplay lines:; At the beginning of the deletion If $OtherControls[$i][1] = 2 Then _ArrayDisplay($OtherControls) $TabItems = ArrayGetByProperty($OtherControls, $TYPE_TAB, $OtherControls[$i][3]) ; And then at the end $OtherControls = $sNewArray _ArrayDisplay($OtherControls) ExitLoopWhen I do this I see that the line elements are all set to 1 after the first deletion, regardless of which button was pressed. I am not prepared to debug that tortuous code in detail to see why it happens - although to my eyes a prime suspect would be: $sNewArray[$ArrayItems][2] = $lineM23  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...
E1M1 Posted March 5, 2011 Author Share Posted March 5, 2011 (edited) Melba23 your's suspect patched 1 bug. now I have $sNewArray[$ArrayItems][2] = $OtherControls[$RealCount][2] But I still have problem that if I click 3rd button 2nd doesn't work anymore. Edit. Found that this line gets it done buggy $OtherControls[$i][1] = 0 but with out this line it wont delete anything. anyone got ideas? Edit: After remove i have item with ID 18 in array but actually this control doesnt exist Edited March 5, 2011 by E1M1 edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 E1M1,Did you try adding those _ArrayDisplay lines as I suggested? If I click button 3, the array grid shows show that you do not remove one of the line 3 items. 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...
E1M1 Posted March 5, 2011 Author Share Posted March 5, 2011 I dont get it. Why it doesnt delete item with ID 18 from array? I know it doesn't remove 1 of line 3 items, but How to I fix this? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> ;write 2 files to disk timeedit() timing() ;read files from disk $list = False If FileExists(@ScriptDir & "\timeedit.eng.lng") Then $list = StringSplit(FileRead(@ScriptDir & "\timeedit.eng.lng"), @CRLF, 1) EndIf $sFileData = FileRead(@ScriptDir & "\timing.lua") Dim $buttons[1] $buttons[0] = "-9999" Dim $OtherControls[1][4] $iTab = 1 $y = 50 $TYPE_HANDLE = 0 $TYPE_TYPE = 1 $TYPE_LINE = 2 $TYPE_TAB = 3 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Timing", 628, 453, 192, 124) If $list[0] > 1 Then WinSetTitle($Form1, "", $list[10]) $Tab1 = GUICtrlCreateTab(0, 0, 625, 417) GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT) $TabSheet1 = GUICtrlCreateTabItem("Mon") If $list[0] > 1 Then GUICtrlSetData(-1, $list[1]) _execute(GetTiming("Monday")) $TabSheet2 = GUICtrlCreateTabItem("Tue") If $list[0] > 1 Then GUICtrlSetData(-1, $list[2]) $y = 50 ;~ _execute(GetTiming("Tuesday")) $TabSheet3 = GUICtrlCreateTabItem("Wed") If $list[0] > 1 Then GUICtrlSetData(-1, $list[3]) $y = 50 ;~ _execute(GetTiming("Wednesday")) $TabSheet4 = GUICtrlCreateTabItem("Thu") If $list[0] > 1 Then GUICtrlSetData(-1, $list[4]) $y = 50 ;~ _execute(GetTiming("Thursday")) $TabSheet5 = GUICtrlCreateTabItem("Fri") If $list[0] > 1 Then GUICtrlSetData(-1, $list[5]) $y = 50 ;~ _execute(GetTiming("Friday")) $TabSheet6 = GUICtrlCreateTabItem("Sat") If $list[0] > 1 Then GUICtrlSetData(-1, $list[6]) $y = 50 ;~ _execute(GetTiming("Saturday")) $TabSheet7 = GUICtrlCreateTabItem("Sun") If $list[0] > 1 Then GUICtrlSetData(-1, $list[7]) $y = 50 ;~ _execute(GetTiming("Sunday")) GUICtrlCreateTabItem("") $Save = GUICtrlCreateButton("Save", 8, 424, 75, 25, $WS_GROUP) If $list[0] > 1 Then GUICtrlSetData(-1, $list[8]) $Reload = GUICtrlCreateButton("Reload", 88, 424, 75, 25, $WS_GROUP) If $list[0] > 1 Then GUICtrlSetData(-1, $list[9]) $new = GUICtrlCreateButton($list[16], 548, 424, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) Func _execute($sStr) Local $handle Local $iLine = 1 $a = StringSplit($sStr, @CRLF, 1) For $i = 1 To $a[0] $handle = Execute($a[$i]) If StringInStr($a[$i], "GUICtrlCreateCombo") Or StringInStr($a[$i], "GUICtrlCreateInput") Or StringInStr($a[$i], "GUICtrlCreateButton") Then ReDim $OtherControls[UBound($OtherControls) + 1][4] $OtherControls[UBound($OtherControls) - 1][0] = $handle $OtherControls[UBound($OtherControls) - 1][1] = CtrlGetType_S($a[$i]) $OtherControls[UBound($OtherControls) - 1][2] = $iLine $OtherControls[UBound($OtherControls) - 1][3] = $iTab If CtrlGetType_S($a[$i]) = 2 Then $iLine += 1 EndIf Next $iTab += 1 EndFunc ;==>_execute Func CtrlGetType_S($sStr) If StringInStr($sStr, "GUICtrlCreateCombo") Then Return 0 EndIf If StringInStr($sStr, "GUICtrlCreateInput") Then Return 1 EndIf If StringInStr($sStr, "GUICtrlCreateButton") Then Return 2 EndIf EndFunc ;==>CtrlGetType_S #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() For $i = 0 To UBound($OtherControls, 1) - 1 If $nMsg = $OtherControls[$i][0] Then If $OtherControls[$i][1] = 2 Then _ArrayDisplay($OtherControls) $TabItems = ArrayGetByProperty($OtherControls, $TYPE_TAB, $OtherControls[$i][3]) $LineItems = ArrayGetByProperty($TabItems, $TYPE_LINE, $OtherControls[$i][2]) $OtherControls[$i][1] = 0 ; make it other than button so loop below would remove it $line = $OtherControls[$i][2] GUICtrlDelete($OtherControls[$i][1]) Local $iCount = 0 ;Increase this to use it later For $n = $i To 0 Step -1 ConsoleWrite($OtherControls[$n][2]&" "&$line) If $OtherControls[$n][2] <> $line Or $n = 0 Then ;if we reached to previous remove button or beginning of array ExitLoop EndIf $iCount += 1 GUICtrlDelete($OtherControls[$n][0]) Next $RealCount = 0 If $n = 0 Then $n = 1 Dim $sNewArray[UBound($OtherControls, 1) - $iCount][4] $line = 1 For $ArrayItems = 1 To UBound($sNewArray, 1) - 1 $RealCount += 1 If $RealCount = $n Then $RealCount += $iCount;use count to deleted controls from array EndIf ;~ ConsoleWrite($ArrayItems& " "&$RealCount&@CRLF) $sNewArray[$ArrayItems][0] = $OtherControls[$RealCount][0] $sNewArray[$ArrayItems][1] = $OtherControls[$RealCount][1] $sNewArray[$ArrayItems][2] = $OtherControls[$RealCount][2] $sNewArray[$ArrayItems][3] = $OtherControls[$RealCount][3] If CtrlGetType_S($sNewArray[$ArrayItems][1]) = 2 Then $Line += 1; CtrlGetType_S returns 2 for button Next ConsoleWrite("Line: " & $OtherControls[$i][2] & " Tab: " & $OtherControls[$i][3] & @CRLF) $OtherControls = $sNewArray _ArrayDisplay($OtherControls) GUICtrlDelete(18) ExitLoop EndIf EndIf Next Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save EndSwitch WEnd Func ArrayGetByProperty($aArray, $iProperty, $val) Dim $aNewArray[1][4] For $i = 0 To UBound($aArray, 1) - 1 If $aArray[$i][$iProperty] = $val Then ReDim $aNewArray[UBound($aNewArray, 1) + 1][4] $aNewArray[UBound($aNewArray, 1) - 1][0] = $aArray[$i][0] $aNewArray[UBound($aNewArray, 1) - 1][1] = $aArray[$i][1] $aNewArray[UBound($aNewArray, 1) - 1][2] = $aArray[$i][2] $aNewArray[UBound($aNewArray, 1) - 1][3] = $aArray[$i][3] EndIf Next Return $aNewArray EndFunc ;==>ArrayGetByProperty Func GetTiming($sDay) $split = StringSplit($sFileData, @CRLF, 1) For $i = 1 To $split[0] $start = StringInStr($split[$i], "function " & $sDay) If $start Then ExitLoop EndIf Next ;~ ConsoleWrite("i = " & $i & @CRLF) For $n = $i To $split[0] $start = StringInStr($split[$n], "Allowed =") If $start Then ExitLoop EndIf Next ;~ ConsoleWrite("n = " & $n & @CRLF) For $a = $n To $split[0] $paramstart = StringInStr($split[$a], "(") If $paramstart Then ExitLoop EndIf Next ;~ ConsoleWrite("a = " & $a & @CRLF) For $b = $a To $split[0] $paramend = StringInStr($split[$b], ")") If $paramend Then ExitLoop EndIf Next ;~ ConsoleWrite("b = " & $b & @CRLF) $fullstr = "" For $c = $a To $b $fullstr &= Interpretate(_RemoveSpace($split[$c])) Next Return $fullstr EndFunc ;==>GetTiming Func Interpretate($sStr) If StringLeft($sStr, 2) = "--" Then Return "" EndIf If StringLen($sStr) < 2 Then Return "" EndIf $words = StringSplit($sStr, " ") $global = "" If $words[0] >= 3 Then For $i = 1 To $words[0] If StringInStr($words[$i], "<") Or StringInStr($words[$i], ">") Or StringInStr($words[$i], "=") Then $data = '' $data &= 'GUICtrlCreateCombo("", ' & 10 + ($i - 1) * 120 & ', ' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"<|>|==|<=|>=|~="') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0xff0000)' & @CRLF EndIf If StringInStr($words[$i], "and") Or StringInStr($words[$i], "or") Then $data = '' $data &= 'GUICtrlCreateCombo("",' & 10 + ($i - 1) * 120 & ',' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"and|or"') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0x0000ff)' & @CRLF EndIf If StringInStr($words[$i], "minute") Or StringInStr($words[$i], "hour") Then $data = '' $data &= 'GUICtrlCreateCombo("", ' & 10 + ($i - 1) * 120 & ',' & $y & ',75)' & @CRLF $data &= 'GUICtrlSetData(-1, ' & luaReplace('"hour|minute"') & ',"' & luaReplace($words[$i]) & '")' & @CRLF $data &= 'GUICtrlSetColor(-1,0xcc00cc)' & @CRLF EndIf If StringIsDigit($words[$i]) Then $data = '' $data &= 'GUICtrlCreateInput("' & luaReplace($words[$i]) & '",' & 10 + ($i - 1) * 120 & ',' & $y & ',75,25)' & @CRLF EndIf $global &= $data ;~ ConsoleWrite($words[$i]&@CRLF) Next EndIf $global &= 'GUICtrlCreateButton("' & $list[15] & '",' & 10 + ($i - 1) * 120 & ',' & $y & ',75,25)' & @CRLF $y += 45 Return $global EndFunc ;==>Interpretate Func luaReplace($sStr) $sStr = StringReplace($sStr, "hour", $list[11]) $sStr = StringReplace($sStr, "minute", $list[12]) $sStr = StringReplace($sStr, "and", $list[13]) $sStr = StringReplace($sStr, "or", $list[14]) Return $sStr EndFunc ;==>luaReplace ; #FUNCTION# ;=============================================================================== ; ; Name...........: _RemoveSpace ; Description ...: Removes spaces and tabs at beginning of string ; Syntax.........: _RemoveSpace($sString) ; Parameters ....: $sString - Input string ; Return values .: $sString with out spaces and tabs at the beginning of string ; Author ........: E1M1 ; Modified.......: ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; No ; ; ;========================================================================================== Func _RemoveSpace($sString) While 1 If StringLeft($sString, 1) = " " Or StringLeft($sString, 1) = @TAB Then $sString = StringTrimLeft($sString, 1) Else Return $sString EndIf WEnd EndFunc ;==>_RemoveSpace Func timeedit() FileDelete(@ScriptDir&"\timeedit.eng.lng") FileWrite(@ScriptDir&"\timeedit.eng.lng",BinaryToString("0x4D6F6E6461790D0A547565736461790D0A5765646E65736461790D0A54687572736461790D0A4672696461790D0A53617475726461790D0A53756E6461790D0A536176650D0A52656C6F61640D0A54696D65730D0A686F75720D0A6D696E7574650D0A616E640D0A6F720D0A72656D6F76650D0A4164640D0A")) endfunc Func timing() FileDelete(@ScriptDir&"\timing.lua") FileWrite(@ScriptDir&"\timing.lua",BinaryToString("0x6E6F77203D206F732E6461746528222A7422293B206C6F63616C20686F75722C6D696E7574652C7765656B646179203D206E6F772E686F75722C6E6F772E6D696E7574652C6E6F772E776461793B0D0A7661726961626C65203D20313233340D0A66756E6374696F6E204973416C6C6F77656428290D0A096C6F63616C204669786564203D20747275650D0A096C6F63616C20416C6C6F776564203D2066616C73650D0A0D0A096966204669786564203D3D2066616C7365207468656E0D0A09096966207765656B646179203D3D2031207468656E20416C6C6F776564203D2053756E64617928290D0A0909656C73656966207765656B646179203D3D2032207468656E20416C6C6F776564203D20204D6F6E64617928290D0A0909656C73656966207765656B646179203D3D2033207468656E20416C6C6F776564203D20205475657364617928290D0A0909656C73656966207765656B646179203D3D2034207468656E20416C6C6F776564203D205765646E657364617928290D0A0909656C73656966207765656B646179203D3D2035207468656E20416C6C6F776564203D20546875727364617928290D0A0909656C73656966207765656B646179203D3D2036207468656E20416C6C6F776564203D2046726964617928290D0A0909656C73656966207765656B646179203D3D2037207468656E20416C6C6F776564203D20536174757264617928290D0A0909656E640D0A09656C73650D0A0909416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A09656E640D0A0D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E204D6F6E64617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E205475657364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E205765646E657364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E20546875727364617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E2046726964617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E20536174757264617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E640D0A0D0A66756E6374696F6E2053756E64617928290D0A09416C6C6F776564203D0D0A0909280D0A090909686F7572203E3D2031360D0A09090909616E64206D696E757465203E3D20300D0A09090909616E64206D696E757465203C2035390D0A0909096F7220686F7572203E3D2031380D0A0909290D0A0972657475726E20416C6C6F7765640D0A656E64")) endfunc edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 E1M1,What torturous code - there must be a simpler way to do whatever it is you are trying to do! Anyway, to solve the proximate problem, just simplify your array deletion code and remove all of the rows with the deleted line using _ArrayDelete like this - look for <<<<<<<<<<<< as usual:expandcollapse popupWhile 1 $nMsg = GUIGetMsg() For $i = 0 To UBound($OtherControls, 1) - 1 If $nMsg = $OtherControls[$i][0] Then If $OtherControls[$i][1] = 2 Then _ArrayDisplay($OtherControls) $TabItems = ArrayGetByProperty($OtherControls, $TYPE_TAB, $OtherControls[$i][3]) $LineItems = ArrayGetByProperty($TabItems, $TYPE_LINE, $OtherControls[$i][2]) $OtherControls[$i][1] = 0 ; make it other than button so loop below would remove it $line = $OtherControls[$i][2] GUICtrlDelete($OtherControls[$i][1]) Local $iCount = 0 ;Increase this to use it later For $n = $i To 0 Step -1 ConsoleWrite($OtherControls[$n][2] & " " & $line) If $OtherControls[$n][2] <> $line Or $n = 0 Then ;if we reached to previous remove button or beginning of array ExitLoop EndIf $iCount += 1 GUICtrlDelete($OtherControls[$n][0]) Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< For $i = UBound($OtherControls) - 1 To 1 Step -1 If $OtherControls[$i][2] = $line Then _ArrayDelete($OtherControls, $i) Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< _ArrayDisplay($OtherControls) ExitLoop EndIf EndIf Next Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Save EndSwitch WEndNow I get all the buttons to work regardless of order. 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...
E1M1 Posted March 5, 2011 Author Share Posted March 5, 2011 (edited) tnx I wish I had brain like you. Edited March 5, 2011 by E1M1 edited Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 5, 2011 Moderators Share Posted March 5, 2011 E1M1, When you have been coding for over 40 years you may well have, But the passage of time does bring some disadvantages too - now where did I put my spectacles? 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...
guinness Posted March 5, 2011 Share Posted March 5, 2011 now where did I put my spectacles?Check they are not on your head UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 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