nitekram Posted December 15, 2010 Share Posted December 15, 2010 ok, so i have a gui filled with input boxes (50+), some of them depend on a value to be entered in another input box to be computed to get a new value. my question, without reading each value and comparing it to the previous value using a temp variable - is there any way to determine if a value has change. Please let there be an easy way! here is what i have using the temp variable, but using this method would create a lot of extra code and variables - is there a better way? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $aInputValues[5], $aTempInputValues[5], $Total = 0, $bChanged = 0 Example1() ; example 1 Func Example1() Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered $aInputValues[0] = GUICtrlCreateInput('', 5, 5, 40) GUICtrlCreateLabel('value one', 75, 5) $aInputValues[1] = GUICtrlCreateInput('', 5, 45, 40) GUICtrlCreateLabel('value two', 75, 45) $aInputValues[2] = GUICtrlCreateInput('', 5, 85, 40) GUICtrlCreateLabel('value three', 75, 85) $aInputValues[3] = GUICtrlCreateInput('', 5, 125, 40) GUICtrlCreateLabel('value four', 75, 125) $aInputValues[4] = GUICtrlCreateInput('', 5, 165, 40) GUICtrlCreateLabel('total', 75, 165) GUISetState(@SW_SHOW) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop For $i = 0 To UBound($aInputValues) - 2 ; do not want to add total to the total If $aTempInputValues[$i] <> GUICtrlRead($aInputValues[$i]) Then If GUICtrlRead($aInputValues[$i]) > '' And $aTempInputValues[$i] <> GUICtrlRead($aInputValues[$i]) Then $aTempInputValues[$i] = GUICtrlRead($aInputValues[$i]) $Total += $aTempInputValues[$i] $bChanged = 1 Else If GUICtrlRead($aInputValues[$i]) = '' Or GUICtrlRead($aInputValues[$i]) = 0 Then $Total -= $aTempInputValues[$i] $aTempInputValues[$i] = GUICtrlRead($aInputValues[$i]) $bChanged = 1 EndIf EndIf EndIf Next If $bChanged Then GUICtrlSetData($aInputValues[4], $Total) $bChanged = 0 ;$Total = 0 EndIf WEnd GUIDelete() EndFunc ;==>Example1 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2010 Moderators Share Posted December 15, 2010 nitekram, I would use a message handler to do the counting only if an input had been changed - cuts down the CPU load a bit: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt('MustDeclareVars', 1) Global $aInputValues[5], $aTempInputValues[5], $Total = 0, $bChanged = 0 Example1() ; example 1 Func Example1() Local $msg GUICreate("My GUI") ; will create a dialog box that when displayed is centered $aInputValues[0] = GUICtrlCreateInput('', 5, 5, 40) GUICtrlCreateLabel('value one', 75, 5) $aInputValues[1] = GUICtrlCreateInput('', 5, 45, 40) GUICtrlCreateLabel('value two', 75, 45) $aInputValues[2] = GUICtrlCreateInput('', 5, 85, 40) GUICtrlCreateLabel('value three', 75, 85) $aInputValues[3] = GUICtrlCreateInput('', 5, 125, 40) GUICtrlCreateLabel('value four', 75, 125) $aInputValues[4] = GUICtrlCreateInput('', 5, 165, 40) GUICtrlCreateLabel('total', 75, 165) GUISetState(@SW_SHOW) ; will display an empty dialog box GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd GUIDelete() EndFunc ;==>Example1 Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iCode = $EN_CHANGE Then ; Has an input been changed? <<<<<<<<<<<<<<<<<<<<<< For $i = 0 To UBound($aInputValues) - 2 If $iIDFrom = $aInputValues[$i] Then ; Is it one of ours? <<<<<<<<<<<<<<<<<<<<<<<<<< $Total = 0 For $j = 0 To UBound($aInputValues) - 2 $Total += GUICtrlRead($aInputValues[$j]) ; Calculate the total <<<<<<<<<<<<<<< Next GUICtrlSetData($aInputValues[4], $Total) ; Display it <<<<<<<<<<<<<<< ExitLoop ; No point in looking any further! <<<<<<<<<<<<<<<<<<<<<< EndIf Next EndIf EndFunc;==>_WM_COMMAND I hope everything is clear - you know what to do if it is not! 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...
nitekram Posted December 15, 2010 Author Share Posted December 15, 2010 WOW - I mean WOW, I wish that I had posted this 3 days ago when i was plulling my hair out. I would have never found this in the help sections, as I would not have been able to find this (not sure even what to search for) - thanks a lot for your help. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2010 Moderators Share Posted December 15, 2010 nitekram, It is not in the Help sections as such - it is one of those little things you pick up as you go along. We could do with some tutorials about the various messages and when they can be useful - I will see what I can put together over the next few weeks. 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...
nitekram Posted December 15, 2010 Author Share Posted December 15, 2010 @M23 Thanks for your help once again - you are an MVP in my book. Let me know when you get a chance to do something like that, it might be helpful in my current script and who knows what I might be able to use for future scripts. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
nitekram Posted December 15, 2010 Author Share Posted December 15, 2010 One more question about this resolution - is there a way to slow down how often it runs the function? The reason I ask is I would like a little bit of time between the calls to allow for more than one digit, if there is more than one. 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 15, 2010 Moderators Share Posted December 15, 2010 (edited) nitekram,If you want to wait a bit, then I would set a timer as an input changes and then not run the "total" function until a certain time has elapsed: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> Opt('MustDeclareVars', 1) Global $aInputValues[5], $iBegin = 0 Example1() ; example 1 Func Example1() Local $msg, $Total GUICreate("My GUI") ; will create a dialog box that when displayed is centered $aInputValues[0] = GUICtrlCreateInput('', 5, 5, 40) GUICtrlCreateLabel('value one', 75, 5) $aInputValues[1] = GUICtrlCreateInput('', 5, 45, 40) GUICtrlCreateLabel('value two', 75, 45) $aInputValues[2] = GUICtrlCreateInput('', 5, 85, 40) GUICtrlCreateLabel('value three', 75, 85) $aInputValues[3] = GUICtrlCreateInput('', 5, 125, 40) GUICtrlCreateLabel('value four', 75, 125) $aInputValues[4] = GUICtrlCreateInput('', 5, 165, 40) GUICtrlCreateLabel('total', 75, 165) GUISetState(@SW_SHOW) ; will display an empty dialog box GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $iBegin Then If TimerDiff($iBegin) > 1000 Then ; wait 1 sec <<<<<<<<<<<<<<< $Total = 0 For $j = 0 To UBound($aInputValues) - 2 $Total += GUICtrlRead($aInputValues[$j]) Next GUICtrlSetData($aInputValues[4], $Total) $iBegin = 0 EndIf EndIf WEnd GUIDelete() EndFunc ;==>Example1 Func MY_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0xFFFF);LoWord Local $iCode = BitShift($wParam, 16) ;HiWord If $iCode = $EN_CHANGE Then For $i = 0 To UBound($aInputValues) - 2 If $iIDFrom = $aInputValues[$i] Then $iBegin = TimerInit() ; Start timer flag ExitLoop EndIf Next EndIf EndFunc;==>_WM_COMMANDYou can adjust the delay in the <<<<<<<<<<< line to meet your personal requirements. M23Edit: Best I put in some <<<<<<<<<<< as I asked you to look for them! Edited December 15, 2010 by Melba23 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...
nitekram Posted December 15, 2010 Author Share Posted December 15, 2010 no wories on the line, i found it after some digging. it appears to have resolve the issue i was having - again thanks for the help 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator 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