Sign in to follow this  
Followers 0
BALA

Help debugging input in code

6 posts in this topic

#include <GUIConstants.au3>

Global $sec = @SEC, $minute, $hour, $light, $time, $clocklabel

Opt("WinWaitDelay", 100)
Opt("GUIOnEventMode", 1)

$mainwindow = GUICreate("BA-LARM", 200, 120, (@DesktopWidth - 188) / 2, (@DesktopHeight - 59) / 2)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$clocklabel = GUICtrlCreateLabel("Loading...", 5, 5, 190, 40, 0x1000)
GUICtrlSetFont($clocklabel, 24)

GUICtrlCreateLabel("Set when alarm should go off:", 10, 60)

$input = GUICtrlCreateInput ("12:00:00",10,80, 65, 20)

$combo = GUICtrlCreateCombo ("AM", 80,80)
GUICtrlSetData(-1,"PM")

Global $inputREAL = GUICtrlRead($input) & " " & GUICtrlRead($combo)

Func CLOSEClicked()
    Exit
EndFunc

Func TimeSet()
    $light = " AM"
    $hour = @HOUR
    $minute = @MIN
    $sec = @SEC
    If $hour = 0 Then
        $hour = 12
    ElseIf $hour = 12 Then
        $light = " PM"
    ElseIf $hour > 12 Then
        $hour = (@HOUR) - 12
        $light = " PM"
    EndIf
    $time = $hour & ":" & $minute & ":" & $sec & $light
    Return $time
EndFunc

Func AlarmCheck($time)
    If $time = $inputREAL Then
        MsgBox(64, "", "The time is currently: " & $inputREAL)
    EndIf
EndFunc

While 1
    If $sec <> @SEC Then
        GUICtrlSetData($clocklabel, TimeSet())
        AlarmCheck(TimeSet())
    EndIf
WEnd

I feel I'm doing something wrong that's really obvious. What is suppose to happen is that a dialog box will come up when the time you set is equal to the current time. Upon closer inspection, I realized that $inputREAL keeps a value of 12:00:00 even if you type in a new time. Anyone have any idea what is wrong?


[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

Wait, I realized what I did wrong, I was setting the time wrong, so really, there was no problem in the code :)

But new problem though:

It works but it still displays the time as 12:00:00 AM when the dialog box pops up.

#include <GUIConstants.au3>

Global $sec = @SEC, $minute, $hour, $light, $time, $clocklabel

Opt("WinWaitDelay", 100)
Opt("GUIOnEventMode", 1)

$mainwindow = GUICreate("BA-LARM", 200, 120, (@DesktopWidth - 188) / 2, (@DesktopHeight - 59) / 2)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$clocklabel = GUICtrlCreateLabel("Loading...", 5, 5, 190, 40, 0x1000)
GUICtrlSetFont($clocklabel, 24)

GUICtrlCreateLabel("Set when alarm should go off:", 10, 60)

$input = GUICtrlCreateInput ("12:00:00",10,80, 65, 20)

$combo = GUICtrlCreateCombo ("AM", 80,80)
GUICtrlSetData(-1,"PM")

Global $inputREAL = GUICtrlRead($input) & " " & GUICtrlRead($combo)

Func CLOSEClicked()
    Exit
EndFunc

Func TimeSet()
    $light = " AM"
    $hour = @HOUR
    $minute = @MIN
    $sec = @SEC
    If $hour = 0 Then
        $hour = 12
    ElseIf $hour = 12 Then
        $light = " PM"
    ElseIf $hour > 12 Then
        $hour = (@HOUR) - 12
        $light = " PM"
    EndIf
    $time = $hour & ":" & $minute & ":" & $sec & $light
    Return $time
EndFunc

While 1
    If $sec <> @SEC Then
        ControlSetText("BA-LARM", "", $clocklabel, TimeSet())
        If $time = GUICtrlRead($input) & " " & GUICtrlRead($combo) Then
            MsgBox(64, "", "The time is currently: " & $inputREAL)
        EndIf
    EndIf
WEnd
Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Thanks, could you explain how that made it work?

In your AlarmCheck function, you are comparing $time against $inputReal which is static value.

You could have your program change to like below also.

While 1
    If $sec <> @SEC Then
        GUICtrlSetData($clocklabel, TimeSet())
        $inputREAL = GUICtrlRead($input) & " " & GUICtrlRead($combo)
        AlarmCheck(TimeSet())
    EndIf
WEnd

Share this post


Link to post
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
Sign in to follow this  
Followers 0