Jump to content

ComboBox updating items


Recommended Posts

I have been trying to get this to work in my script...after creating an example script to ask a question, my original reason for writing the example was resolved. But I then found another issue that I am having trouble figuring out.

What I want is a combo list that is dynamic. I want the list to remove items that have been selected, and add items that have been changed. I have am still trying to resolve, but thought I would post it and see if I can get an answer.

; example of removing combo items, and updating the combo list for all remaining combos - including those that already have been asigned
#include <GUIConstantsEx.au3>
#include <array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0
; create the value of the combo list - using array to create values
For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
;_ArrayDisplay($aComboList)
Global $aTempArray = $aComboList
; convert the array into a string that can be used on a combo control
Global $sComboString = _ArrayToString($aComboList)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    If $x = 1 Then
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10)
        GUICtrlSetData(-1, $sComboString)
    Else
        $ahCombo[$x] = GUICtrlCreateCombo('', 10, 10 + $iCount)
        GUICtrlSetData(-1, $sComboString)
    EndIf
    $iCount += 30
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)
; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            RemoveIndex($ahCombo[$x]) ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next

WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func RemoveIndex($hItem)
    ;_GUICtrlComboBox_GetList (not being used)
    Local $sTempComboValue = ''
    Local $sComboListTemp

    ConsoleWrite('Removing Item from Array - ' & GUICtrlRead($hItem) & @CRLF)
    For $x = UBound($aTempArray) - 1 To 0 Step -1
        If GUICtrlRead($hItem) = $aTempArray[$x] Then
            _ArrayDelete($aTempArray, $x)
            ;
            ExitLoop
        EndIf
    Next
    ;_ArrayDisplay($aTempArray)
    ; update all combos to the new string
    $sComboListTemp = _ArrayToString($aTempArray)
    For $x = 0 To UBound($ahCombo) - 1

        If GUICtrlRead($ahCombo[$x]) = '' Then
            ; if nothing has been selected, update with new combo list for future selection
            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sComboListTemp)

        ElseIf GUICtrlRead($ahCombo[$x]) <> '' Then
            ; if value already exist then keep value
            $sTempComboValue = GUICtrlRead($ahCombo[$x])
            ; set new combo list for this item

            For $y = UBound($aTempArray) - 1 To 0 Step -1
                If $aTempArray[$y] = '' Then
                    _ArrayDelete($aTempArray, $y)
                    $sComboListTemp = _ArrayToString($aTempArray)
                EndIf
            Next




; need a way to add the value back, if there was an item removed from selection for the calling control, and it is not being used elsewhere
#cs

            ;If Not StringInStr($sComboListTemp, $sTempComboValue) Then $sComboListTemp &= '|' & $sTempComboValue

            ; check for selected value being used, if it is not being used, then reinsert
            Local $sNewComboList = ''
            For $z = 1 To UBound($ahCombo) - 1
                If $z = UBound($ahCombo) - 1 Then ExitLoop
                $sNewComboList &= GUICtrlRead($ahCombo[$z]) & '|'
            Next
            Local $aNewComboList = StringSplit($sNewComboList, '|', 2)
            ;_ArrayDisplay($aNewComboList)

            ; Compare the strings
            $sNewComboList &= $sComboListTemp & $sComboString

            $aTempArray = _ArrayUnique($aNewComboList)
            _ArrayDisplay($aTempArray)
            _ArrayAdd($aTempArray, '')
            $sNewComboList = _ArrayToString($aTempArray)
#ce


            GUICtrlSetData($ahCombo[$x], '')
            GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sComboListTemp, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sTempComboValue & '|' & $sNewComboList, $sTempComboValue)
            ;GUICtrlSetData($ahCombo[$x], $sNewComboList, $sTempComboValue)
        EndIf

    Next
EndFunc   ;==>RemoveIndex

 

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

That was a fun little problem. This seems to work for me - does it meet your requirements?

#include <GUIConstantsEx.au3>
#include <Array.au3>

Global $aComboList[16], $ahCombo[16], $iCount = 0

For $x = 1 To UBound($aComboList) - 1
    $aComboList[$x] = $x
Next
Global $sComboString = _ArrayToString($aComboList)
ConsoleWrite($sComboString & @CRLF)

; create the gui
Global $hGUI = GUICreate('Combo Remove Test', 250, 475)
; create the combos
For $x = 1 To UBound($ahCombo) - 1
    $ahCombo[$x] = GUICtrlCreateCombo('', 10, (30 * $x) - 20)
    GUICtrlSetData(-1, $sComboString)
Next

; Display the GUI.
GUISetState(@SW_SHOW, $hGUI)

; main loop
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    ; check if values have been updated in on the combo controls
    For $x = 1 To UBound($ahCombo) - 1
        If $ahCombo[$x] = $msg Then
            _AlterCombos() ; delete the value from the string, so it cannot be used in other combos
        EndIf
    Next
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Func _AlterCombos()

    ; Capy the original full data string - add final "|" for matching
    $sNewString = $sComboString & "|"

    ; Now remove all currently selected items
    For $i = 1 To UBound($ahCombo) - 1
        If GUICtrlRead($ahCombo[$i]) Then
            $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($ahCombo[$i]) & "|", "|")
        EndIf
    Next
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($ahCombo) - 1
        $sCurrSel = GUICtrlRead($ahCombo[$i])
        $sThisString = $sNewString & "|" & $sCurrSel
        GUICtrlSetData($ahCombo[$i], $sThisString, $sCurrSel)
    Next

EndFunc   ;==>_AlterCombos

M23

Edited by Melba23
Amended code to cater for edge case

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

That worked as planned...guess I was trying to complicate it. Sometimes I would just like to watch the thought processes of the coders here, that know what they are doing.

 

Thanks again.

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."

 

WindowsError.gif

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

Okay, on the surface, it works, but not for my script. I tried to make an easy example, but it was two easy. I have more combo boxes, with different arrays, pulling from the same string. I might be able to figure this out, when I am less tired, but when working on this for a few hours before posting.

Here is my code...though I just started it - if anyone finds a way to make it smaller, please share.

 

Still trying to do the same thing...make is so once the item is picked, remove from string, and if it is available, add it back to the string.

; choir keeper
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>

Global $cDaysOff = '0x00ff00'
Global $aTime[23]
Global $aSunday[5][6], $aMonday[5][6], $aTuesday[5][6], $aWednesday[5][6], $aThursday[5][6], $aFriday[5][6], $aSaturday[5][6]
Global $sComboChores = ''
Global $aChores[23][3] = [ _
        ['Kitchen', False, $aTime[1]], _
        ['Master Bed Room', False, $aTime[2]], _
        ['Front Bed Room', False, $aTime[3]], _
        ['Back Bed Room', False, $aTime[4]], _
        ['Bathroom Full', False, $aTime[5]], _
        ['Bathroom Half', False, $aTime[6]], _
        ['Living Room', False, $aTime[7]], _
        ['Dining Bar', False, $aTime[8]], _
        ['Dining Porch', False, $aTime[9]], _
        ['Basement', False, $aTime[10]], _
        ['Garage', False, $aTime[11]], _
        ['Laundry Room', False, $aTime[12]], _
        ['Lawn (Cutting)', False, $aTime[13]], _
        ['Storage', False, $aTime[14]], _
        ['Porch', False, $aTime[15]], _
        ['Closed Porch', False, $aTime[16]], _
        ['Weed Pulling', False, $aTime[17]], _
        ['Misc1', False, $aTime[18]], _
        ['Misc2', False, $aTime[19]], _
        ['Misc3', False, $aTime[20]], _
        ['Misc4', False, $aTime[21]], _
        ['Misc5', False, $aTime[22]]]
;_ArrayDisplay($aChores)


; need
; timer - how long does it take
; choir name
; choir type - full, half, straighten
; week/day
; person name
; calendar
;
CreateSchedule()
; calandar
Func CreateSchedule()
    Local $hMainGui = GUICreate('Chore List', 1200, 525)
    Local $iCountDown = 70
    GUICtrlCreateLabel('Week One', 10, $iCountDown)
    ;
    GUICtrlCreateLabel('Week Two', 10, $iCountDown + 115)
    ;
    GUICtrlCreateLabel('Week Three', 10, $iCountDown + 230)
    ;
    GUICtrlCreateLabel('Week Four', 10, $iCountDown + 345)
    ;
    ;
    Local $iSpace = 155
    GUICtrlCreateLabel('Sunday', $iSpace, 10)
    GUICtrlCreateLabel('Monday', $iSpace * 2, 10)
    GUICtrlCreateLabel('Tuesday', $iSpace * 3, 10)
    GUICtrlCreateLabel('Wednesday', $iSpace * 4, 10)
    GUICtrlCreateLabel('Thursday', $iSpace * 5, 10)
    GUICtrlCreateLabel('Friday', $iSpace * 6, 10)
    GUICtrlCreateLabel('Saturday', $iSpace * 7, 10)
    $iCountDown = 20
    Local $iSideStep = 155

    ;$sComboChores = _ArrayToString($aChores)
    ;#cs
    ; create combo list
    For $x = 1 To UBound($aChores) - 1
        If $x = UBound($aChores) - 1 Then
            $sComboChores &= $aChores[$x][0]
        Else
            $sComboChores &= '|' & $aChores[$x][0];& '|'
        EndIf
    Next
    ;#ce
    ;
    ;
    Local $iJumpDown = 0, $iJumpOver = 0, $iWeek = 1
    For $x = 1 To UBound($aSunday) - 1
        $aSunday[$x][0] = 'Sunday Week' & $iWeek
        For $y = 1 To UBound($aSunday, 2) - 1
            $aSunday[$x][$y] = GUICtrlCreateCombo('', 110, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aMonday) - 1
        $aMonday[$x][0] = 'Monday Week' & $iWeek
        For $y = 1 To UBound($aMonday, 2) - 1
            $aMonday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aTuesday) - 1
        $aTuesday[$x][0] = 'Tuesday Week' & $iWeek
        For $y = 1 To UBound($aTuesday, 2) - 1
            $aTuesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 2, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aWednesday) - 1
        $aWednesday[$x][0] = 'Wednesday Week' & $iWeek
        For $y = 1 To UBound($aWednesday, 2) - 1
            $aWednesday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 3, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aThursday) - 1
        $aThursday[$x][0] = 'Thursday Week' & $iWeek
        For $y = 1 To UBound($aThursday, 2) - 1
            $aThursday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 4, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aFriday) - 1
        $aFriday[$x][0] = 'Friday Week' & $iWeek
        For $y = 1 To UBound($aFriday, 2) - 1
            $aFriday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 5, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    ;
    ;
    $iJumpDown = 0
    $iWeek = 1
    For $x = 1 To UBound($aSaturday) - 1
        $aSaturday[$x][0] = 'Saturday Week' & $iWeek
        For $y = 1 To UBound($aSaturday, 2) - 1
            $aSaturday[$x][$y] = GUICtrlCreateCombo('', 110 + $iSideStep * 6, 25 + $iCountDown * 2 + $iJumpDown, 130, 15) ; 105 height
            GUICtrlSetBkColor(-1, '0x00ff00')
            GUICtrlSetData(-1, $sComboChores)
            $iJumpDown += 21
        Next
        $iWeek += 1
        $iJumpDown += 10
    Next
    GUISetState(@SW_SHOW, $hMainGui)

    While 1
        $msg = GUIGetMsg()

        If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        For $x = 1 To UBound($aSunday) - 1
            For $y = 1 To UBound($aSunday, 2) - 1
                If $msg = $aSunday[$x][$y] Then
                    ;UpdateComboList($aSunday)
                    ;UpdateComboList($aMonday)
                    UpdateChoreList('','','')
                    ;UpdateChoreList(GUICtrlRead($aSunday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aSunday[$x][$y]))
                    ;UpdateChoreList($aSunday[$x][$y], GUICtrlRead($aSunday[$x][$y]), $sComboChores)
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aMonday) - 1
            For $y = 1 To UBound($aMonday, 2) - 1
                If $msg = $aMonday[$x][$y] Then
                    UpdateChoreList('','','')
                    ;UpdateComboList($aMonday)
                    ;UpdateChoreList($aMonday[$x][$y], GUICtrlRead($aMonday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aMonday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aTuesday) - 1
            For $y = 1 To UBound($aTuesday, 2) - 1
                If $msg = $aTuesday[$x][$y] Then
                    UpdateComboList($aTuesday)
                    ;UpdateChoreList($aTuesday[$x][$y], GUICtrlRead($aTuesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aTuesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aWednesday) - 1
            For $y = 1 To UBound($aWednesday, 2) - 1
                If $msg = $aWednesday[$x][$y] Then
                    UpdateComboList($aWednesday)
                    ;UpdateChoreList($aWednesday[$x][$y], GUICtrlRead($aWednesday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aWednesday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aThursday) - 1
            For $y = 1 To UBound($aThursday, 2) - 1
                If $msg = $aThursday[$x][$y] Then
                    UpdateComboList($aThursday)
                    ;UpdateChoreList($aThursday[$x][$y], GUICtrlRead($aThursday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aThursday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aFriday) - 1
            For $y = 1 To UBound($aFriday, 2) - 1
                If $msg = $aFriday[$x][$y] Then
                    UpdateComboList($aFriday)
                    ;UpdateChoreList($aFriday[$x][$y], GUICtrlRead($aFriday[$x][$y]), $sComboChores) ;MsgBox('', '', GUICtrlRead($aFriday[$x][$y]))
                EndIf
            Next
        Next
        ;
        For $x = 1 To UBound($aSaturday) - 1
            For $y = 1 To UBound($aSaturday, 2) - 1
                If $msg = $aSaturday[$x][$y] Then
                    UpdateComboList($aSaturday)
                    ;UpdateChoreList($aSaturday[$x][$y], GUICtrlRead($aSaturday[$x][$y]), $sComboChores) ; MsgBox('', '', GUICtrlRead($aSaturday[$x][$y]))
                EndIf
            Next
        Next
    WEnd

    GUIDelete($hMainGui)

    ;_ArrayDisplay($aSunday)
EndFunc   ;==>CreateSchedule
;
Func UpdateChoreList($hControl, $sDeleteFromList, $sComboChorestemp)
    #cs
    Local $aTempCombo = StringSplit($sComboChorestemp, '|', 2)
    ;_ArrayDisplay($aTempCombo)
    ;_ArrayDisplay($aTempCombo)
    For $x = UBound($aTempCombo) - 1 To 0 Step -1
        If $sDeleteFromList = $aTempCombo[$x] Then
            MsgBox('', '$sDeleteFromList', $sDeleteFromList)
            _ArrayDelete($aTempCombo, $x)
            _ArrayDelete($aChores, $x)
            ExitLoop
        EndIf
    Next
    ;Return

    $sComboChores = ''
    $sComboChores = _ArrayToString($aTempCombo)
    ;GUICtrlSetData($hControl, '')
    ;GUICtrlSetData($hControl, $sComboChores, $sDeleteFromList)
    #ce
    ;UpdateComboList($hControl)

    UpdateComboList($aSunday)
    UpdateComboList($aMonday)
    UpdateComboList($aTuesday)
    UpdateComboList($aWednesday)
    UpdateComboList($aThursday)
    UpdateComboList($aFriday)
    UpdateComboList($aSaturday)



EndFunc   ;==>UpdateChoreList
;

;



Func UpdateComboList($aArray)
    ;MsgBox('','$sComboChores',$sComboChores)
    ;
    ; Capy the original full data string - add final "|" for matching
    Local $sNewString = $sComboChores & "|"


    ;Local $sTempValue = GUICtrlRead($hControl), $sAnother = ''

    ; Now remove all currently selected items
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            If GUICtrlRead($aArray[$i][$j]) Then
                $sNewString = StringReplace($sNewString, "|" & GUICtrlRead($aArray[$i][$j]) & "|", "|")
                ConsoleWrite($sNewString)
            EndIf
            ConsoleWrite(@CRLF)
        Next
    Next

    ;MsgBox('','', $sNewString)
    ; Remove final "|"
    $sNewString = StringTrimRight($sNewString, 1)

    ; Change the data for each combo - restoring the currently selected item for those that have one
    For $i = 1 To UBound($aArray) - 1
        For $j = 1 To UBound($aArray, 2) - 1
            $sCurrSel = GUICtrlRead($aArray[$i][$j])
            $sThisString = $sNewString & "|" & $sCurrSel
            ;GUICtrlSetData($aSunday[$i][$j], '')
            GUICtrlSetData($aArray[$i][$j], $sThisString, $sCurrSel)
        Next
    Next
$sComboChores = $sThisString
    #cs
        For $x = 1 To UBound($aSunday) - 1
        For $y = 1 To UBound($aSunday, 2) - 1
        If GUICtrlRead($aSunday[$x][$y]) = '' Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Or GUICtrlRead($hControl) <> '' Then
        If GUICtrlRead($hControl) = GUICtrlRead($aSunday[$x][$y]) Then

        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ElseIf GUICtrlRead($aSunday[$x][$y]) <> '' Then
        ConsoleWrite('1 ' & @CRLF)
        $sAnother = GUICtrlRead($aSunday[$x][$y])
        ;
        ;$sComboChores = $sAnother & '|' & $sComboChores
        ;
        GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sAnother & '|' & $sComboChores, $sAnother)
        EndIf
        Else

        EndIf
        Next
        Next

        If $sTempValue = GUICtrlRead($aSunday[$x][$y]) Then
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        Then
        GUICtrlSetData($aSunday[$x][$y], '')
        GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores, $sTempValue)
        Else
        ;GUICtrlSetData($aSunday[$x][$y], '')
        ;GUICtrlSetData($aSunday[$x][$y], $sComboChores)
        EndIf
        EndIf

    #ce
    #cs
        For $x = 1 To UBound($aMonday) - 1
        For $y = 1 To UBound($aMonday, 2) - 1
        If GUICtrlRead($aMonday[$x][$y]) = '' Then
        GUICtrlSetData($aMonday[$x][$y], '')
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aMonday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aTuesday) - 1
        For $y = 1 To UBound($aTuesday, 2) - 1
        If GUICtrlRead($aTuesday[$x][$y]) = '' Then
        GUICtrlSetData($aTuesday[$x][$y], '')
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aTuesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aWednesday) - 1
        For $y = 1 To UBound($aWednesday, 2) - 1
        If GUICtrlRead($aWednesday[$x][$y]) = '' Then
        GUICtrlSetData($aWednesday[$x][$y], '')
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aWednesday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aThursday) - 1
        For $y = 1 To UBound($aThursday, 2) - 1
        If GUICtrlRead($aThursday[$x][$y]) = '' Then
        GUICtrlSetData($aThursday[$x][$y], '')
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aThursday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aFriday) - 1
        For $y = 1 To UBound($aFriday, 2) - 1
        If GUICtrlRead($aFriday[$x][$y]) = '' Then
        GUICtrlSetData($aFriday[$x][$y], '')
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aFriday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
        For $x = 1 To UBound($aSaturday) - 1
        For $y = 1 To UBound($aSaturday, 2) - 1
        If GUICtrlRead($aSaturday[$x][$y]) = '' Then
        GUICtrlSetData($aSaturday[$x][$y], '')
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        Else
        GUICtrlSetData($aSaturday[$x][$y], $sComboChores)
        EndIf
        Next
        Next
    #ce
EndFunc   ;==>UpdateComboList

Thanks again for any help

 

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

Just how do you want this to work? Obviously the "5-a-day" choices need to be unique, but what about as you proceed through the week? Is it each chore once a week only or can they appear several times? And presumably each week is an entirely separate entity?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@M23

All great questions...I will have to think about that, before I ask for your help. I do not want to waste your time, if I later change my mind later - so better make sure what I want first.

I will answer this question tomorrow - thanks for making me think it out.

 

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

better make sure what I want first

A very good idea! Now if only other posters would adopt the same principle.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Okay, I had a long drive home...I now know what I want - but not sure if possible (may be a bid tedious)

I want the function I call to have a parameter (1, 2, 4) ONE would be each week, TWO would divide the 4 weeks into two sections, and FOUR would be over all 4 weeks.

EDIT

If possible can you comment it, so I can follow the process of your brain?

 

EDIT 2

If the array scheme that I have now makes it harder, I am not worried if it needs to be changed to make it easier. If you need it changed, just let me know, and I will make the change, and repost it.

 

EDIT 3

In fact, I am sure you want me to change it, as I can see it being easier to divide everything into weeks???

Edited by nitekram

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

Good job it was a rainy afternoon! That was a really fun problem - and I think I have a solution.  Play around with this and see if it does what you want:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>

;         Chore,            interval (1, 2, 4 weeks),   Count in week 1,2,3,4
Global $aChoresBase[][] = [ _
        ['Kitchen',         1,                          0, 0, 0, 0], _
        ['Master Bed Room', 1,                          0, 0, 0, 0], _
        ['Front Bed Room',  2,                          0, 0, 0, 0], _
        ['Back Bed Room',   2,                          0, 0, 0, 0], _
        ['Bathroom Full',   1,                          0, 0, 0, 0], _
        ['Bathroom Half',   2,                          0, 0, 0, 0], _
        ['Living Room',     1,                          0, 0, 0, 0], _
        ['Dining Bar',      1,                          0, 0, 0, 0], _
        ['Dining Porch',    2,                          0, 0, 0, 0], _
        ['Basement',        4,                          0, 0, 0, 0], _
        ['Garage',          4,                          0, 0, 0, 0], _
        ['Laundry Room',    2,                          0, 0, 0, 0], _
        ['Lawn (Cutting)',  2,                          0, 0, 0, 0], _
        ['Storage',         4,                          0, 0, 0, 0], _
        ['Porch',           2,                          0, 0, 0, 0], _
        ['Closed Porch',    2,                          0, 0, 0, 0], _
        ['Weed Pulling',    2,                          0, 0, 0, 0], _
        ['Misc1',           4,                          0, 0, 0, 0], _
        ['Misc2',           4,                          0, 0, 0, 0], _
        ['Misc3',           4,                          0, 0, 0, 0], _
        ['Misc4',           4,                          0, 0, 0, 0], _
        ['Misc5',           4,                          0, 0, 0, 0]]

_ArrayDisplay($aChoresBase, "Original", Default, 8) ; Display only

; Create combo list
$sChoreListBase = ""
For $i = 0 To UBound($aChoresBase) - 1
    $sChoreListBase &= "|" & $aChoresBase[$i][0]
Next

Global $cCombo_Start

CreateSchedule()

Func CreateSchedule()

    Local $hMainGui = GUICreate('Chore List', 1200, 540)

    ; Create labels
    Local $iWeekSpacing = 125, $iWeekOffset = 90
    For $i = 1 To 4
        GUICtrlCreateLabel('Week ' & $i, 10, ($i * $iWeekSpacing) - $iWeekOffset)
    Next
    Local $iDaySpacing = 155, $iDayOffset = 45
    Local $aDay[8] = ["", 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
    For $i = 1 To 7
        GUICtrlCreateLabel($aDay[$i], $iDaySpacing * ($i) - $iDayOffset, 10, 125, 20, $SS_CENTER)
    Next

    ; Create combos
    $cCombo_Start = GUICtrlCreateDummy() + 1 ; ControlID of first combo
    Local $iComboOffset = 21, $iChoresPerDay = 5
    For $i = 1 To 4 ; Weeks
        $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
        For $j = 1 To 7 ; Days
            $iX = ($iDaySpacing * $j) - $iDayOffset
            For $k = 0 To $iChoresPerDay - 1 ; Chores
                $iY = $iY_Base + ($iComboOffset * $k)
                GUICtrlCreateCombo("", $iX, $iY, 125, 20)
                GUICtrlSetData(-1, $sChoreListBase)
            Next
        Next
    Next
    $cCombo_End = GUICtrlCreateDummy() - 1 ; ControlID of last combo

    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $cCombo_Start To $cCombo_End ; Combo actioned
                _Update_Combos()
        EndSwitch
    WEnd


EndFunc

Func _Update_Combos()

    ; Read data from all combos into new blank chores array
    Local $aChores = $aChoresBase
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo setting - ControlID calculated
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            If $sSel Then
                ; Find index of selected chore in the array
                $iIndex = _ArraySearch($aChores, $sSel)
                ; Set for correct week
                $aChores[$iIndex][$i + 2] += 1
            EndIf
        Next
    Next
    _ArrayDisplay($aChores, "Up To Date", Default, 8) ; Display only

    ; Copy base combo list - one for each week
    Local $aChoreList[5] = ["", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|", $sChoreListBase & "|"]

    ; Now run through chores and decide if interval criteria met
    For $i = 0 To UBound($aChores) - 1
        ; Check required interval
        Switch $aChores[$i][1]
            Case 1 ; Once per week
                For $j = 1 To 4
                    ; So if chosen in this week
                    If $aChores[$i][$j + 1] Then
                        ; Remove from the list for this week only
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from List " & $j & @CRLF)
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    EndIf
                Next
            Case 2 ; Once every 2 weeks
                ; Split into 2 x 2-week sections
                For $k = 0 To 2 Step 2
                    ; If chosen in this section
                    $iCount = 0
                    For $j = 1 To 2
                        $iCount += $aChores[$i][$j + $k + 1]
                    Next
                    If $iCount Then
                        $sLists = ( ($k) ? ("3 & 4") : ("1 & 2") )
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)
                        ; Remove from both lists for this section
                        For $j = 1 + $k To 2 + $k
                            $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                        Next
                    EndIf
                Next
            Case 4 ; Once every 4 weeks
                ; If chosen
                $iCount = 0
                For $j = 1 To 4
                    $iCount += $aChores[$i][$j + 1]
                Next
                If $iCount Then
                    ; Remove from all lists
                    ConsoleWrite("Removing " & $aChores[$i][0] & " from ALL Lists" & @CRLF)
                    For $j = 1 To 4
                        $aChoreList[$j] = StringReplace($aChoreList[$j], "|" & $aChores[$i][0] & "|", "|")
                    Next
                EndIf
        EndSwitch
    Next
    _ArrayDisplay($aChoreList, "Combo Data Lists", Default, 8) ; Display only

    ; Now fill combos
    For $i = 0 To 3 ; Weeks
        For $j = 0 To 34 ; Combos
            ; Read combo
            $sSel = GUICtrlRead($cCombo_Start + $j + ($i * 35))
            ; Get data string for this week
            $sData = StringTrimRight($aChoreList[$i + 1], 1)
            ; Add current selection if required
            If $sSel Then
                $sData &= "|" & $sSel
            EndIf
            ; Load combo
            GUICtrlSetData($cCombo_Start + $j + ($i * 35), $sData, $sSel)
        Next
    Next

EndFunc

Please do ask if anything is unclear - although I have tried to comment liberally,it is not always easy to make things as clear as they appear to the original coder.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

First off - I am amazed at how short it is. I know it will work, but I am having an issue running it.

ERROR: (132,23) : ERROR: syntax error (illegal character)

$sLists = (($k) ? ("3 & 4") :("1 & 2"))

I do not know this code, and I tried to do a search in the help file, but that was pointless - can you tell me what this is called?

 

EDIT

I commented out these two line and am starting to play with it - I will be back soon

;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
;ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

 

EDIT 2

I actually got that code to work, changed it to - but would still like to learn this new syntax

If $k = 3 Or $k = 4 Then
                            $sLists = "3 & 4"
                        Else
                            $sLists = "1 & 2"
                        EndIf
                        ;$sLists = (($k) ? ("3 & 4") :("1 & 2"))
                        ConsoleWrite("Removing " & $aChores[$i][0] & " from Lists " & $sLists & @CRLF)

Edited by nitekram

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

it is an example of the ternary operator that was introduced in v3.3.10.0 (23rd December, 2013) - you are obviously a good couple of releases behind me!

Just replace that line by these and all will work as expected:

$sLists = "1 & 2"
If $k Then $sLists = "3 & 4"

And that line is only for display purposes anyway.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Okay...I am amazed. This is far more than I wanted, for your thought processes is at a higher level than mine. I never even thought of making each choir like that, where each one will have its own schedule.

I want to thank you...I will come back with questions on how you did something/things. Hope you do not mind me picking your brain?

Got to get some sleep now. Working graveyard is not fun, but at least I have AutoIt to keep me company.

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

Hope you do not mind me picking your brain?

Of course not - ask away.

M23 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Okay, starting with the questions...

First can you explain the thought process in getting the format of the labels and combo boxes - maybe pseudo code of what you are doing. I see what you did, but not sure how you got there - if that makes any sense. I mean you see mine, and how long it took me to copy and paste, and copy and paste, and you get the idea.

Edited by nitekram
spelling

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."

 

WindowsError.gif

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

Second...I have not used the Dummy control for quite some time, and only once. What is it and why are you using it? Is that like using an array, without using an array, to be able to get the control IDs handle?

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

Creating grids of controls

If you ever have to create any controls that are in a regular pattern (the labels and combos in this script are a perfect example) then it is nearly always quicker (and certainly shorter) to do so in a loop and to use an algorithm (short formula) to determine the coordinates of each one as they are created. As the combos are the most complex, let us start with them.

Obviously we need to decide some of the constant values before we begin - the spacing between each column and row, how many in each column and row, etc. Then we need to decide the order in which we want to create them to ease subsequent coding - in this case we were looking to differentiate the weeks, so creating the weeks in succession seemed a good way to go, so we start with the week loop and determine the vertical position of the first combo of each block. The formula is very simple (and used in all 3 loops) - the spacing increases by the same amount for each pass and the offset makes sure the first pass is at the correct value:

For $i = 1 To 4 ; Weeks
  $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset ; These values were already defined when we created the week labels

Now we will be creating 7 blocks of combos, one for each day so we need to create these in succession making another loop inside the first - inside which we determine the horizontal position of each block:

For $j = 1 To 7 ; Days
   $iX = ($iDaySpacing * $j) - $iDayOffset ; Again, these values were determined when we created the day labels.

Finally we need to create a combos in the block - each one will be slightly lower than its predecessor, so we use a final loop to calculate the vertical position based on the initial value we determined in the outer loop above:

For $k = 0 To $iChoresPerDay - 1 ; Chores
    $iY = $iY_Base + ($iComboOffset * $k)

Now we have the X & Y coordinates for each combo and can create it in the correct place.  Here is a short script to show the values inside the loops and the order in which the controls are created (plus their ControlIDs in parentheses - (see below why this is of interest):

#include <GUIConstantsEx.au3>

Local $hMainGui = GUICreate('Chore List', 1200, 540)

GUISetState()

; The constants required
Local $iWeekSpacing = 125, $iWeekOffset = 90
Local $iDaySpacing = 155, $iDayOffset = 45
Local $iComboOffset = 21, $iChoresPerDay = 5

; The 3 loops
For $i = 1 To 4 ; Weeks
    $iY_Base = ($i * $iWeekSpacing) - $iWeekOffset
    For $j = 1 To 7 ; Days
        $iX = ($iDaySpacing * $j) - $iDayOffset
        For $k = 0 To $iChoresPerDay - 1 ; Chores
            $iY = $iY_Base + ($iComboOffset * $k)
            $cCID = GUICtrlCreateLabel("", $iX, $iY, 125, 20)
            GUICtrlSetData($cCID, $i & " - " & $j & " - " & $k & " > (" & $cCID & ")")
            GUICtrlSetBkColor($cCID, 0xFFCCCC)
            Sleep(100)
        Next
    Next
Next

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Dummy Controls

Dummies can be very useful - in this script we use them to determine the values of the first and last combos created as the dummies obviously have the ControlIDs just before/after the first/last combo created. This is a trick which only works because AutoIt normally assigns the ControlIDs in numerical succession (it can fail to do this if controls have previously been created and deleted, but that is not the case here) which enables us to loop through the controls one by one. Remember that I mentioned above we wanted to  divide the controls into weeks in the outer loop? As a result the ControlIDs run as you can see in the example above: n to n+34 in the first week, n+35 to n+69 in the second, and so on - and it is now easy to loop through each week's set of combos when deciding whether a certain value has been set.

I hope that is sufficiently clear - please ask again if not.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23,

I may be going back to some older scripts and doing a redesign...I think this part that you wrote, should some how make it the help file or something, as it would help others as well. As far as learning this...I guess it is the algorithm, that is stumping me. How do you go about creating/solving it, and knowing when to use it?

And I again, thank you for your time, explaining this layout to me...I do believe that example that you wrote is just, well beautiful.

I now have to get some good questions about the refresh of the combos - after trying to figure it out. I will be back lol

 

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

The algorithm is in fact very simple - increase a parameter each time you go through a loop - but the trick is doing it in 2/3D as we do here. You can use it whenever you have to create controls in some form of pattern (it is particularly well-suited to grids) where the spacing can be calculated by a simple formula. As to the actual formula - I try and work it out in paper first and then run a simulation script to test that the values I have chosen actually work. And of course, you will nearly always need some form of constant to adjust for the initial position - even Einstein needed one of those, so I have no problem doing the same.

Standing by for the "combo refresh" questions!

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

M23,

I think I will stay away from learning gravity, until I am older, as I will be even closer to the ground - Einstein created a constant in space, so I guess I can start making things up, and only crap my pants, if someone asks me to prove it lol

Okay, I see these offsets are coming in handy, as you also are using them to get past the array indexes that are not part of the loop - I am learning more everyday!

I got all the way to the second case (split into 2 weeks) statement - with understanding, but I am lost...there is a lot going on. May we start with the $iCount, and how it comes into play, I mean my mind is hurting trying to figure it out - LET ALONE how would I begin to even think this way and write it.

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."

 

WindowsError.gif

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

  • Moderators

nitekram,

Let us take the whole function (which is called each time a combo is actioned) and break it down:

First we create a copy of the $aChores array so we can see what is and is not set this time around.

Then we read all the combos - see how we can read each week in turn by running through in sections of 35. Then if there is a value already set, we find the element of the $aChores array that matches the selected chore and set the correct "week" element (which we can easily calculate from the week number). Now we will have the array filled with all the currently selected chores and the weeks in which they have been selected.

We then create a $aChoreList array with each week being given a full list of the chores to carry out - we need to have 4 as some chores are weekly and might still be selectable in other weeks. The next task is to remove from each list those chores which are already being carried out - so first we need to check how often the chores need to be done: once a week means remove from that week only; every 2 weeks means removes from a 2 week block if already done; while every 4 weeks means remove from all of  lists. We run through each chore in turn and Switch depending on the frequency set (1, 2, 4).

- If 1 (each week) then we look at each week in turn to see if that chore is already selected - the "week" element of the $aChores array will have been set if it is - and if so, remove that chore from that week's list in the $aChoreList array.

- If 2 (every 2 weeks) then we need to look at 2-week blocks (1-2 & 3-4) - and we use 2 loops to do this. The outer loop runs twice with values of 0 and 2, while the inner runs twice from 1 to 2. Adding them means we get the values 1, 2, 3, 4 which nicely matches the week numbering. Inside the 2 loops we check both of the "week" elements of the $aChores array for the 2-week block and if the chore is selected, remove it from both of the lists for those weeks in the $aChoreList array.

- If every 4 weeks then the problem becomes a little simpler - we need a single loop to check each of the "week" elements of the $aChores array and if the chore is set, remove it from all of the lists in the $aChoreList array.

We now have the $aChoreList array filled with 4 lists of the remaining chores for each week. We run yet another loop to fill each week's combos with their respective list - not forgetting to add back the currently displayed value and set it as the default.

And Robert is your mother's brother! Does that make the script clearer?

As to the thought processes I used to develop this - it is mostly a question of logic.  I will try and reconstruct what I did.

You wanted to have 1,2,4 week intervals which forces us to store the required interval, so why not in the same array as the chores themselves?  Using this same array to store the chores already selected in each week is therefore a sensible choice as it keeps everything together.

The next step follows on from something I learnt a long time ago and which I pass on with pleasure. When faced with a long repetitive task (such as which combos need changing) humans tend to look for the changes so as to minimize the number of times things need to be done.  However, computers are usually faster running the whole list of tasks as that means there are fewer conditional statements to run for each item - and they are usually so fast that humans do not notice the passage of time required in any event. So when a combo is actioned we do not look at that particular combo, we just read the whole set and recalculate and reset the combo contents for the entire GUI.  It seems illogical, but believe me it is usually by far the best and fastest way to go about things.

The chore removal logic is the same as I developed for your first query - just expanded to cater for the fact that we have 4 separate lists for the 4 weeks. As I have mentioned previously, choosing the right data structure and loop elements initially makes subsequent coding easier - this is I am afraid mostly (painfully gained) experience and there is no magic formula. But I would stress that it often pays to go back and completely restructure your initial data storage and various loop parameters if by so doing you can make the intensive parts of the script easier to code - the time spent is well worth it in terms of clarity of code and speed of execution.

So there you have it - any more questions?

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...