Jump to content

MVP Help Needed for Appointments App.


Recommended Posts

I am posting this after many weeks of agony over the situation. I have been working on a reminder program, where you input your scheduled appointments, and upon opening the program, a list of your appointments will appear.

now the script is pretty basic. easy to read and understand, since i dont mind having long variables, to know exactly which is doing what. My problem is that i am using a .ini file to save the appointments in. the Date is the section, the Time is the key, and the details is the value. The script i am posting is my latest attempt, since _ArraySort for a 1D array arranged numbers for example 1, 10, 11, 12, 2, 21, 22, 3, 31, etc..

In this script I am assigning the section names into a 2D array using a simple For-Next loop, and sorting them by column 0. I did this because in the example script for _ArraySort() it has a 2D array sorting method, and if you change the numbers to be what i've given as an example, it will sort them properly 1,2,3,4,5,6,7,8,9,10,11,12. However in my script, it doesn't do so. it does the same 1, 10, 2, 21, 3, 33, etc..

I need some serious help on figuring out how to get _ArraySort() to sort the dates by month properly, OR another method that will list the dates in order, for the readout of scheduled appointments.

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array1.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Reminders", 400, 318, 303, 123)
GUISetCursor(3)
GUISetBkColor(0x0A246A)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$List1 = GUICtrlCreateList("", 160, 8, 233, 305, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlSetColor(-1, 0xFFFFFF)
$Date = GUICtrlCreateDate("", 8, 8, 146, 21, $WS_TABSTOP)
$Time = GUICtrlCreateDate("", 8, 32, 146, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
$Edit1 = GUICtrlCreateEdit("", 8, 64, 145, 129, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Add = GUICtrlCreateButton("Add", 40, 216, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $File = @ScriptDir & "\Reminders.ini"
Global $n = 0

_OpeningFunction()

While 1
    Sleep(100)
WEnd

Func _OpeningFunction()
    If FileExists($File) Then
        Global $dateList = IniReadSectionNames($File)
        Local $dateList2D[$dateList[0]][3]
        For $k = 1 To $dateList[0]
            $selDate = StringSplit($dateList[$k], "/")
            $selDateYear = $selDate[3]
            $selDateMonth = $selDate[1]
            $selDateDay = $selDate[2]
            $dateList2D[$k - 1][0] = $selDateMonth
            $dateList2D[$k - 1][1] = $selDateDay
            $dateList2D[$k - 1][2] = $selDateYear
        Next
        $CurrentYear = @YEAR
        $CurrentMonth = Number(@MON)
        $CurrentDay = Number(@MDAY)
        _ArraySort($dateList2D, 0, 0, 0, 0)
        For $i = 1 To $dateList[0]
            If $dateList2D[$i - 1][2] = $CurrentYear Then
                If $dateList2D[$i - 1][0] = $CurrentMonth Then
                    If $dateList2D[$i - 1][1] < $CurrentDay Then
                        IniDelete($File, $dateList[$i])
                    EndIf
                    If $dateList2D[$i - 1][1] = $CurrentDay And $n = 0 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "Today's Schedule")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    ElseIf $i >= $dateList[0] And $n = 0 Then
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "No Scheduled Appointments Today")
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                    If $dateList2D[$i - 1][1] > $CurrentDay And $n = 1 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "__________________________________")
                        _GUICtrlListBox_InsertString($List1, $dateList[$i])
                        _GUICtrlListBox_InsertString($List1, " ")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                ElseIf $dateList2D[$i - 1][0] > $CurrentMonth And $n = 2 Then
                    $selMonth = IniReadSection($File, $dateList[$i])
                    _GUICtrlListBox_BeginUpdate($List1)
                    _GUICtrlListBox_InsertString($List1, "__________________________________")
                    _GUICtrlListBox_InsertString($List1, $dateList[$i])
                    _GUICtrlListBox_InsertString($List1, " ")
                    For $j = 1 To $selMonth[0][0]
                        _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                    Next
                    _GUICtrlListBox_UpdateHScroll($List1)
                    _GUICtrlListBox_EndUpdate($List1)
                EndIf
            EndIf
            If $i >= $dateList[0] Then
                $n = $n + 1
            EndIf
        Next
        If $n <= 3 Then
            _OpeningFunction()
        EndIf
    EndIf
EndFunc   ;==>_OpeningFunction

Func Button1Click() ; Add
    $setDate = GUICtrlRead($Date)
    $setTime = GUICtrlRead($Time)
    $setTimeSplit = StringSplit($setTime, ":")
    $AmPm = StringRight($setTime, 2)
    $setTimeHM = String($setTimeSplit[1] & ":" & $setTimeSplit[2] & " " & $AmPm)
    IniWrite($File, $setDate, $setTimeHM, GUICtrlRead($Edit1))
EndFunc   ;==>Button1Click
Func Form1Close()
    Exit
EndFunc   ;==>Form1Close
Func Form1Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc   ;==>Form1Minimize
Func Form1Restore()
    GUISetState(@SW_RESTORE)
EndFunc   ;==>Form1Restore

ANY AND ALL HELP WILL BE GRATEFULLY APPRECIATED, AND WILL RECIEVE THANKS

FILE FOR .AU3 DOWNLOAD = Reminders.au3

PLEASE ADD RANDOMLY DATED APPOINTMENTS TO ENSURE YOU UNDERSTAND WHAT I MEAN

and a way to keep the list in real time for added appointments would be spectacular.

Edited by WarPathGrim
Link to comment
Share on other sites

he want, but you requested MVP-s help so probably he will not :mellow:

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

What does this do:

Local $dateList2D[$dateList[0]][3]
        For $k = 1 To $dateList[0]
            $selDate = StringSplit($dateList[$k], "/")
            $selDateYear = Number($selDate[3])
            $selDateMonth = Number($selDate[1])
            $selDateDay = Number($selDate[2])
            $dateList2D[$k - 1][0] = $selDateMonth
            $dateList2D[$k - 1][1] = $selDateDay
            $dateList2D[$k - 1][2] = $selDateYear
        Next

Edit:

BTW, I simple SQLite DB would probably be much more proficient with much less work.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

_ArrayDisplay($dateList2D)
        $count = UBound($dateList2D)-1
        For $x = 0 To $count
            If StringLen($dateList2D[$x][0]) = 1 Then $dateList2D[$x][0] = "0"&$dateList2D[$x][0]
            If StringLen($dateList2D[$x][1]) = 1 Then $dateList2D[$x][1] = "0"&$dateList2D[$x][1]
        Next
        _ArraySort($dateList2D, 0, 0, 0, 0)
        _ArrayDisplay($dateList2D)

probably something like this is needed

basicly add "0" infront of number if its 1 Len and then try sorting

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

What does this do:

Local $dateList2D[$dateList[0]][3]
        For $k = 1 To $dateList[0]
            $selDate = StringSplit($dateList[$k], "/")
            $selDateYear = Number($selDate[3])
            $selDateMonth = Number($selDate[1])
            $selDateDay = Number($selDate[2])
            $dateList2D[$k - 1][0] = $selDateMonth
            $dateList2D[$k - 1][1] = $selDateDay
            $dateList2D[$k - 1][2] = $selDateYear
        Next

that changes the section names, or dates of the appointments, into a 2D array. simply using stringsplit wouldnt be a 2D array, and $selDate[0] would be a number that isn't a date, it would be the amount. so i made $dateList2D[0][0] a date instead of a count of arrays returned.

could you provide an example of what you mean?

@bogQ

i'll give that a shot and see what happens.

nothing changed. putting the 0 back at the front of numbers less than 10 didnt change the outcome of if

Edited by WarPathGrim
Link to comment
Share on other sites

yes i totally messed up that -1 :mellow:

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

WarPathGrim you have problem probably elsewhere, after sorting use _ArrayDisplay($dateList2D) to see the results the sort isnt reflecting in the gui writing

from this

[0]|1|8|2011

[1]|11|8|2011

[2]|2|8|2011

[3]|21|8|2011

[4]|23|8|2011

[5]|27|8|2011

[6]|28|8|2011

i got this

[0]|01|08|2011

[1]|02|08|2011

[2]|11|08|2011

[3]|21|08|2011

[4]|23|08|2011

[5]|27|08|2011

[6]|28|08|2011

so sorting is working Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

WarPathGrim,

This works for me - does it for you? :mellow:

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#Include <Date.au3>

Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode", 1)

Global $File = @ScriptDir & "\Reminders.ini"
Global $n = 0

$Form1 = GUICreate("Reminders", 400, 318, 303, 123)
GUISetCursor(3)
GUISetBkColor(0x0A246A)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$List1 = GUICtrlCreateList("", 160, 8, 233, 305, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlSetColor(-1, 0xFFFFFF)
$Date = GUICtrlCreateDate("", 8, 8, 146, 21, $WS_TABSTOP)
$Time = GUICtrlCreateDate("", 8, 32, 146, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
$Edit1 = GUICtrlCreateEdit("", 8, 64, 145, 129, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Add = GUICtrlCreateButton("Add", 40, 216, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)

_OpeningFunction()

While 1
    Sleep(10)
WEnd

Func _OpeningFunction()
    If FileExists($File) Then
        Global $dateList = IniReadSectionNames($File)
        _ArraySort($dateList, 0, 1)
        Local $dateList2D[$dateList[0]][3], $selDateYear, $selDateMonth, $selDateDay
        For $k = 1 To $dateList[0]
            _DayValueToDate(Number($dateList[$k]), $selDateYear, $selDateMonth, $selDateDay)
            $dateList2D[$k - 1][0] = $selDateMonth
            $dateList2D[$k - 1][1] = $selDateDay
            $dateList2D[$k - 1][2] = $selDateYear
        Next
        $CurrentYear = @YEAR
        $CurrentMonth = Number(@MON)
        $CurrentDay = Number(@MDAY)
        ;_ArraySort($dateList2D, 0, 0, 0, 0)
        For $i = 1 To $dateList[0]
            If $dateList2D[$i - 1][2] = $CurrentYear Then
                If $dateList2D[$i - 1][0] = $CurrentMonth Then
                    If $dateList2D[$i - 1][1] < $CurrentDay Then
                        IniDelete($File, $dateList[$i])
                    EndIf
                    If $dateList2D[$i - 1][1] = $CurrentDay And $n = 0 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "Today's Schedule")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    ElseIf $i >= $dateList[0] And $n = 0 Then
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "No Scheduled Appointments Today")
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                    If $dateList2D[$i - 1][1] > $CurrentDay And $n = 1 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "__________________________________")
                        _GUICtrlListBox_InsertString($List1, $dateList2D[$i - 1][0] & "/" & $dateList2D[$i - 1][1] & "/" & $dateList2D[$i - 1][2])
                        _GUICtrlListBox_InsertString($List1, " ")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                ElseIf $dateList2D[$i - 1][0] > $CurrentMonth And $n = 2 Then
                    $selMonth = IniReadSection($File, $dateList[$i])
                    _GUICtrlListBox_BeginUpdate($List1)
                    _GUICtrlListBox_InsertString($List1, "__________________________________")
                    _GUICtrlListBox_InsertString($List1, $dateList2D[$i - 1][0] & "/" & $dateList2D[$i - 1][1] & "/" & $dateList2D[$i - 1][2])
                    _GUICtrlListBox_InsertString($List1, " ")
                    For $j = 1 To $selMonth[0][0]
                        _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                    Next
                    _GUICtrlListBox_UpdateHScroll($List1)
                    _GUICtrlListBox_EndUpdate($List1)
                EndIf
            EndIf
            If $i >= $dateList[0] Then
                $n = $n + 1
            EndIf
        Next
        If $n <= 3 Then
            _OpeningFunction()
        EndIf
    EndIf
EndFunc   ;==>_OpeningFunction

Func Button1Click() ; Add
    $aDate = StringSplit(GUICtrlRead($Date), "/")
    $setDate = Number(_DateToDayValue($aDate[3], $aDate[2], $aDate[1]))
    $setTime = GUICtrlRead($Time)
    $setTimeSplit = StringSplit($setTime, ":")
    $AmPm = StringRight($setTime, 2)
    $setTimeHM = String($setTimeSplit[1] & ":" & $setTimeSplit[2] & " " & $AmPm)
    IniWrite($File, $setDate, $setTimeHM, GUICtrlRead($Edit1))
EndFunc   ;==>Button1Click
Func Form1Close()
    Exit
EndFunc   ;==>Form1Close
Func Form1Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc   ;==>Form1Minimize
Func Form1Restore()
    GUISetState(@SW_RESTORE)
EndFunc   ;==>Form1Restore

If it does, I will explain what I did - unless you can work it out yourself, of course! :)

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

I cant see it in the thread

Give an example of a section name.

EDIT:

and whats in your Array1.au3?

Array1.au3 is the Array.au3 file from the beta include folder. an example of the section name would be 8/23/2011

WarPathGrim you have problem probably elsewhere, after sorting use _ArrayDisplay($dateList2D) to see the results the sort isnt reflecting in the gui writing

from this

i got this

so sorting is working

i did use arraydisplay.. it shows the arrays in 1, 11, 2, 22, that i stated earlier.

WarPathGrim,

This works for me - does it for you? :mellow:

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#Include <Date.au3>

Opt("TrayMenuMode", 1)
Opt("GUIOnEventMode", 1)

Global $File = @ScriptDir & "\Reminders.ini"
Global $n = 0

$Form1 = GUICreate("Reminders", 400, 318, 303, 123)
GUISetCursor(3)
GUISetBkColor(0x0A246A)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$List1 = GUICtrlCreateList("", 160, 8, 233, 305, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlSetColor(-1, 0xFFFFFF)
$Date = GUICtrlCreateDate("", 8, 8, 146, 21, $WS_TABSTOP)
$Time = GUICtrlCreateDate("", 8, 32, 146, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
$Edit1 = GUICtrlCreateEdit("", 8, 64, 145, 129, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Add = GUICtrlCreateButton("Add", 40, 216, 75, 25, $WS_GROUP)
GUICtrlSetOnEvent(-1, "Button1Click")
GUISetState(@SW_SHOW)

_OpeningFunction()

While 1
    Sleep(10)
WEnd

Func _OpeningFunction()
    If FileExists($File) Then
        Global $dateList = IniReadSectionNames($File)
        _ArraySort($dateList, 0, 1)
        Local $dateList2D[$dateList[0]][3], $selDateYear, $selDateMonth, $selDateDay
        For $k = 1 To $dateList[0]
            _DayValueToDate(Number($dateList[$k]), $selDateYear, $selDateMonth, $selDateDay)
            $dateList2D[$k - 1][0] = $selDateMonth
            $dateList2D[$k - 1][1] = $selDateDay
            $dateList2D[$k - 1][2] = $selDateYear
        Next
        $CurrentYear = @YEAR
        $CurrentMonth = Number(@MON)
        $CurrentDay = Number(@MDAY)
        ;_ArraySort($dateList2D, 0, 0, 0, 0)
        For $i = 1 To $dateList[0]
            If $dateList2D[$i - 1][2] = $CurrentYear Then
                If $dateList2D[$i - 1][0] = $CurrentMonth Then
                    If $dateList2D[$i - 1][1] < $CurrentDay Then
                        IniDelete($File, $dateList[$i])
                    EndIf
                    If $dateList2D[$i - 1][1] = $CurrentDay And $n = 0 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "Today's Schedule")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    ElseIf $i >= $dateList[0] And $n = 0 Then
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "No Scheduled Appointments Today")
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                    If $dateList2D[$i - 1][1] > $CurrentDay And $n = 1 Then
                        $selMonth = IniReadSection($File, $dateList[$i])
                        _GUICtrlListBox_BeginUpdate($List1)
                        _GUICtrlListBox_InsertString($List1, "__________________________________")
                        _GUICtrlListBox_InsertString($List1, $dateList2D[$i - 1][0] & "/" & $dateList2D[$i - 1][1] & "/" & $dateList2D[$i - 1][2])
                        _GUICtrlListBox_InsertString($List1, " ")
                        For $j = 1 To $selMonth[0][0]
                            _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                        Next
                        _GUICtrlListBox_UpdateHScroll($List1)
                        _GUICtrlListBox_EndUpdate($List1)
                    EndIf
                ElseIf $dateList2D[$i - 1][0] > $CurrentMonth And $n = 2 Then
                    $selMonth = IniReadSection($File, $dateList[$i])
                    _GUICtrlListBox_BeginUpdate($List1)
                    _GUICtrlListBox_InsertString($List1, "__________________________________")
                    _GUICtrlListBox_InsertString($List1, $dateList2D[$i - 1][0] & "/" & $dateList2D[$i - 1][1] & "/" & $dateList2D[$i - 1][2])
                    _GUICtrlListBox_InsertString($List1, " ")
                    For $j = 1 To $selMonth[0][0]
                        _GUICtrlListBox_InsertString($List1, $selMonth[$j][0] & "  " & $selMonth[$j][1])
                    Next
                    _GUICtrlListBox_UpdateHScroll($List1)
                    _GUICtrlListBox_EndUpdate($List1)
                EndIf
            EndIf
            If $i >= $dateList[0] Then
                $n = $n + 1
            EndIf
        Next
        If $n <= 3 Then
            _OpeningFunction()
        EndIf
    EndIf
EndFunc   ;==>_OpeningFunction

Func Button1Click() ; Add
    $aDate = StringSplit(GUICtrlRead($Date), "/")
    $setDate = Number(_DateToDayValue($aDate[3], $aDate[2], $aDate[1]))
    $setTime = GUICtrlRead($Time)
    $setTimeSplit = StringSplit($setTime, ":")
    $AmPm = StringRight($setTime, 2)
    $setTimeHM = String($setTimeSplit[1] & ":" & $setTimeSplit[2] & " " & $AmPm)
    IniWrite($File, $setDate, $setTimeHM, GUICtrlRead($Edit1))
EndFunc   ;==>Button1Click
Func Form1Close()
    Exit
EndFunc   ;==>Form1Close
Func Form1Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc   ;==>Form1Minimize
Func Form1Restore()
    GUISetState(@SW_RESTORE)
EndFunc   ;==>Form1Restore

If it does, I will explain what I did - unless you can work it out yourself, of course! :)

M23

you sorted the array directly from inireadsectionnames instead of the array i assigned myself, but that didnt work for me.. i dont understand how it could be working for you guys, but not for me. I have the most recent updates...

in my Reminders.ini file I added 3 appointments for this month, 1 for each month after. No matter where i put the _ArraySort, it always returned "10,11,12,8,8,8,9" in the _ArrayDisplay, and therefore in the list.

And the list can't be the problem, since it assigns the data in the list directly in order its recieved if the month is greater than the current month. So using that in the list readout it would do 8/24/2011 details, 8/25/2011 details, 8/26/2011 details, 10/11/2011 details, 11/30/2011 details, and 12/24/2011 details.

Edited by WarPathGrim
Link to comment
Share on other sites

  • Moderators

WarPathGrim,

Sorry, I should have mentioned: delete any existing ini files and create a new one - otherwise my solution will not work. :mellow:

you sorted the array directly from inireadsectionnames instead of the array i assigned myself

A bit more than that - which is why you need a new ini file created by the script I posted. :)

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

WarPathGrim,

Sorry, I should have mentioned: delete any existing ini files and create a new one - otherwise my solution will not work. :mellow:

A bit more than that - which is why you need a new ini file created by the script I posted. :)

M23

well i deleted my file and used your script entirely.. i added something for tday, then i added for october, december, november, and september in that order, and the only thing that showed in the list was the december appointment
Link to comment
Share on other sites

  • Moderators

WarPathGrim,

Well it works for me - doing exactly as you have just said:

Sorry it does not for you - I am out. :mellow:

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

Here's what I'd do

Not modified your script, I'd break it :mellow:

Instead of splitting the ini dated, I'd create a new array with a second colum as a datediff between today and the date in ini.

I'm lousey at explaining so heres an example.

#include <Date.au3>
#include <Array.au3>

Local $aDatesFromIni[3] = ["8/29/2011", "8/25/2011", "9/01/2011"]
_ArrayDisplay($aDatesFromIni, "Original")
Local $aDatesToSort[3][2]

For $i = 0 To 2
    $aDatesToSort[$i][0] = $aDatesFromIni[$i]
    $aDatesToSort[$i][1] = _DateDiff("D",_NowCalc(), _Convert($aDatesFromIni[$i]))
Next

_ArrayDisplay($aDatesToSort, "Sort")

_ArraySort($aDatesToSort)

_ArrayDisplay($aDatesToSort, "Sorted")

Func _Convert($date); needed to convert the date to the correct format
    Local $new = ""
    $atmp = StringSplit($date,"/",3)
    $new &= $atmp[2] & "/" & $atmp[0] & "/" & $atmp[1]
    Return $new
EndFunc

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

this is my starting point (note that i dont use ini and that my date is splited with '.' and i dont have AP PM instead i have seconds , diffrent comp settings display diffrent date formats and time)

#include <ButtonConstants.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#Include <File.au3>

$Form1 = GUICreate("Reminders", 400, 318, 303, 123)

GUISetCursor(3)
GUISetBkColor(0x0A246A)

$List1 = GUICtrlCreateList("", 160, 8, 233, 305, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetBkColor(-1, 0x0A246A)
GUICtrlSetColor(-1, 0xFFFFFF)

$Date = GUICtrlCreateDate("", 8, 8, 146, 21, $WS_TABSTOP)
$Time = GUICtrlCreateDate("", 8, 32, 146, 21, BitOR($DTS_UPDOWN, $DTS_TIMEFORMAT, $WS_TABSTOP))
$Edit1 = GUICtrlCreateEdit("", 8, 64, 145, 129, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL))

$Add = GUICtrlCreateButton("Add", 40, 216, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
_OpeningFunction()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Form1Close()
        Case $msg = $GUI_EVENT_MINIMIZE
            Form1Minimize()
        Case $msg = $GUI_EVENT_RESTORE
            Form1Restore()
        Case $msg = $Add
            Button1Click()
    EndSelect
    Sleep(10)
WEnd


Func _OpeningFunction()
    Dim $Farr
    _FileReadToArray("test.txt",$Farr)
    If Not @error Then
        Local $Sarr[$Farr[0]][3]
        For $k = 1 To $Farr[0]
            $S1 = StringSplit($Farr[$k],"   ")
            $Sarr[$k-1][0] = $S1[1]
            $Sarr[$k-1][1] = $S1[2]
            $Sarr[$k-1][2] = $S1[3]
        Next
        _ArrayDisplay($Sarr)
        _ArraySort($Sarr, 0, 0, 0, 0)
        _ArrayDisplay($Sarr)
    EndIf
EndFunc   ;==>_OpeningFunction


Func Button1Click() ; Add
    $SetTime = GUICtrlRead($Time)
    $setDate = StringSplit(GUICtrlRead($Date), '.')
    If StringLen($setDate[1]) = 1 Then $setDate[1] = '0'&$setDate[1]
    If StringLen($setDate[2]) = 1 Then $setDate[2] = '0'&$setDate[2]
    $setDate = $setDate[1]&'.'&$setDate[2]&'.'&$setDate[3]
    FileWrite("test.txt",$setDate&" "&$setTime&"    "&GUICtrlRead($Edit1)&@CRLF)
EndFunc   ;==>Button1Click


Func Form1Close()
    Exit
EndFunc   ;==>Form1Close


Func Form1Minimize()
    GUISetState(@SW_MINIMIZE)
EndFunc   ;==>Form1Minimize


Func Form1Restore()
    GUISetState(@SW_RESTORE)
EndFunc   ;==>Form1Restore

Personal opinion, he should rewrite it all

its 2 large mess in there to poke around trying to finde why after working sort it dont work

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

that changes the section names, or dates of the appointments, into a 2D array. simply using stringsplit wouldnt be a 2D array, and $selDate[0] would be a number that isn't a date, it would be the amount. so i made $dateList2D[0][0] a date instead of a count of arrays returned.

could you provide an example of what you mean?

You're complaining that the numbers are not sorting correctly.

The reason they aren't sorting correctly is because you are sorting strings not numbers.

I showed you how to over come that by turning the string into a number.

----

Now, it's your job as a programmer/coder to fix it later in the script.

You could have done:

Local $dateList2D[$dateList[0]][3]
        For $k = 1 To $dateList[0]
            $selDate = StringSplit($dateList[$k], "/")
            $selDateYear = $selDate[3]
            $selDateMonth = $selDate[1]
            $selDateDay = $selDate[2]
            $dateList2D[$k - 1][0] = Number($selDateMonth)
            $dateList2D[$k - 1][1] = Number($selDateDay)
            $dateList2D[$k - 1][2] = Number($selDateYear)
        Next
        $CurrentYear = @YEAR
        $CurrentMonth = Number(@MON)
        $CurrentDay = Number(@MDAY)
        _ArraySort($dateList2D, 0, 0, 0, 0)
        ; fix array to format back to date format
        For $ic = 0 To UBound($dateList2D) - 1
            $dateList2D[$ic][0] = StringFormat("%02d", $dateList2D[$ic][0])
            $dateList2D[$ic][1] = StringFormat("%02d", $dateList2D[$ic][1])
        Next

Edit:

I still think an SQLite DB would be much better here.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...