Sign in to follow this  
Followers 0
Arclite86

if and Endif problem

10 posts in this topic

its supposed to be a clock that when you activate this function it wil give +5 min

;$Input12= minutes
;$Input11= hour
;$Input10= day

 If GUICtrlRead($Input12) < 60  Then   ;minutes
                GUICtrlSetData($Input12, GUICtrlRead($Input12) + 5)
            ElseIf GUICtrlRead($Input12) = 60 Then
                GUICtrlSetData($Input12, 0)
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
EndIf


  If GUICtrlRead($Input11) < 24 Then
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            ElseIf GUICtrlRead($Input11) = 24 Then
                GUICtrlSetData($Input11, 0)
                GUICtrlSetData($Input10, GUICtrlRead($Input10) + 1)
            EndIf 

the minutes are working for every 6 clicks ( 6*5(min)) +1 hour

but everytime I activate this  it also gives +1 hour

I dont understand this  I clearly set $input11 <24 (hour) then......

could somebody help me with this

 

Share this post


Link to post
Share on other sites



yes off course

#include <GUIConstantsEx.au3>


$Form1_1_1_1 = GUICreate("forum", 773, 489, 247, 202)
$Input8 = GUICtrlCreateInput("2014", 480, 440, 33, 21)
$jaar = GUICtrlCreateLabel("jaar", 488, 424, 21, 17)
$Input9 = GUICtrlCreateInput("05", 512, 440, 33, 21)
$maand = GUICtrlCreateLabel("maand", 512, 424, 36, 17)
$Input10 = GUICtrlCreateInput("01", 544, 440, 33, 21)
$dag = GUICtrlCreateLabel("dag", 552, 424, 22, 17)
$Input11 = GUICtrlCreateInput("12", 584, 440, 33, 21)
$uur = GUICtrlCreateLabel("uur", 592, 424, 19, 17)
$Input12 = GUICtrlCreateInput("05", 616, 440, 33, 21)
$min = GUICtrlCreateLabel("min", 624, 424, 20, 17)
$Input13 = GUICtrlCreateInput("02", 648, 440, 33, 21)
$sec = GUICtrlCreateLabel("sec", 656, 424, 21, 17)
$plus = GUICtrlCreateButton("5min", 680, 440, 33, 25)
$1min = GUICtrlCreateButton("1min", 712, 440, 33, 25)
GUISetState()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE

            case $plus
         If GUICtrlRead($Input12) < 60  Then
                GUICtrlSetData($Input12, GUICtrlRead($Input12) + 5)
            ElseIf GUICtrlRead($Input12) = 60 Then
                GUICtrlSetData($Input12, 0)
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
EndIf


  If GUICtrlRead($Input11) < 24 Then
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            ElseIf GUICtrlRead($Input11) = 24 Then
                GUICtrlSetData($Input11, 0)
                GUICtrlSetData($Input10, GUICtrlRead($Input10) + 1)
            EndIf
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

There is an "Exit" statement missing.

  Case $GUI_EVENT_CLOSE
   Exit   <=====
 


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

There is an "Exit" statement missing.

  Case $GUI_EVENT_CLOSE

   Exit   <=====

 

yes sorry i forgot that, but that was not the problem that i was trying to solve :)

Share this post


Link to post
Share on other sites

#include <GUIConstantsEx.au3>


$Form1_1_1_1 = GUICreate("forum", 773, 489, 247, 202)
$Input8 = GUICtrlCreateInput("2014", 480, 440, 33, 21)
$jaar = GUICtrlCreateLabel("jaar", 488, 424, 21, 17)
$Input9 = GUICtrlCreateInput("05", 512, 440, 33, 21)
$maand = GUICtrlCreateLabel("maand", 512, 424, 36, 17)
$Input10 = GUICtrlCreateInput("01", 544, 440, 33, 21)
$dag = GUICtrlCreateLabel("dag", 552, 424, 22, 17)
$Input11 = GUICtrlCreateInput("12", 584, 440, 33, 21)
$uur = GUICtrlCreateLabel("uur", 592, 424, 19, 17)
$Input12 = GUICtrlCreateInput("05", 616, 440, 33, 21)
$min = GUICtrlCreateLabel("min", 624, 424, 20, 17)
$Input13 = GUICtrlCreateInput("02", 648, 440, 33, 21)
$sec = GUICtrlCreateLabel("sec", 656, 424, 21, 17)
$plus = GUICtrlCreateButton("5min", 680, 440, 33, 25)
$1min = GUICtrlCreateButton("1min", 712, 440, 33, 25)
GUISetState()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $plus
            If GUICtrlRead($Input12) < 60 Then
                GUICtrlSetData($Input12, GUICtrlRead($Input12) + 5)
            ElseIf GUICtrlRead($Input12) = 60 Then
                GUICtrlSetData($Input12, 0)
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            EndIf
                    
            #cs
            If GUICtrlRead($Input11) < 24 Then
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            ElseIf GUICtrlRead($Input11) = 24 Then
                GUICtrlSetData($Input11, 0)
                GUICtrlSetData($Input10, GUICtrlRead($Input10) + 1)
            EndIf
            #ce
    EndSwitch
WEnd


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
#include <GUIConstantsEx.au3>


$Form1_1_1_1 = GUICreate("forum", 773, 489, 247, 202)
$Input8 = GUICtrlCreateInput("2014", 480, 440, 33, 21)
$jaar = GUICtrlCreateLabel("jaar", 488, 424, 21, 17)
$Input9 = GUICtrlCreateInput("05", 512, 440, 33, 21)
$maand = GUICtrlCreateLabel("maand", 512, 424, 36, 17)
$Input10 = GUICtrlCreateInput("01", 544, 440, 33, 21)
$dag = GUICtrlCreateLabel("dag", 552, 424, 22, 17)
$Input11 = GUICtrlCreateInput("12", 584, 440, 33, 21)
$uur = GUICtrlCreateLabel("uur", 592, 424, 19, 17)
$Input12 = GUICtrlCreateInput("05", 616, 440, 33, 21)
$min = GUICtrlCreateLabel("min", 624, 424, 20, 17)
$Input13 = GUICtrlCreateInput("02", 648, 440, 33, 21)
$sec = GUICtrlCreateLabel("sec", 656, 424, 21, 17)
$plus = GUICtrlCreateButton("5min", 680, 440, 33, 25)
$1min = GUICtrlCreateButton("1min", 712, 440, 33, 25)
GUISetState()


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $plus
            If GUICtrlRead($Input12) < 60 Then
                GUICtrlSetData($Input12, GUICtrlRead($Input12) + 5)
            ElseIf GUICtrlRead($Input12) = 60 Then
                GUICtrlSetData($Input12, 0)
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            EndIf
                    
            #cs
            If GUICtrlRead($Input11) < 24 Then
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            ElseIf GUICtrlRead($Input11) = 24 Then
                GUICtrlSetData($Input11, 0)
                GUICtrlSetData($Input10, GUICtrlRead($Input10) + 1)
            EndIf
            #ce
    EndSwitch
WEnd

Thank you but why is the hour (uur) input passing 24 and the "day" input doesnt give +1 after 24 hour

Share this post


Link to post
Share on other sites

Because it was not being checked, was just showing how hours minutes could work.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $plus
            If GUICtrlRead($Input12) < 60 Then
                GUICtrlSetData($Input12, GUICtrlRead($Input12) + 5)
            ElseIf GUICtrlRead($Input12) = 60 Then
                GUICtrlSetData($Input12, 0)
                GUICtrlSetData($Input11, GUICtrlRead($Input11) + 1)
            EndIf

            If GUICtrlRead($Input11) = 24 Then
                GUICtrlSetData($Input11, 0)
                GUICtrlSetData($Input10, GUICtrlRead($Input10) + 1)
            EndIf

    EndSwitch
WEnd

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

ok thank very much for you help JohnOne :)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Just another solution without if/endif.

#include <GUIConstantsEx.au3>
#include <Date.au3>
#include <array.au3>
Opt("GUICoordMode", 0)

$GUI = GUICreate("forum", 773, 489, 247, 202)
GUICtrlCreateLabel("YYYY   MM  DD     hh   mm   ss", 488, 424)
$year = GUICtrlCreateInput(@YEAR, 0, 16, 33)
$mon = GUICtrlCreateInput(@MON, 35, 0, 20)
$day = GUICtrlCreateInput(@MDAY, 22, 0, 20)
$hour = GUICtrlCreateInput(@HOUR, 33, 0, 20)
$min = GUICtrlCreateInput(@MIN, 22, 0, 20)
$sec = GUICtrlCreateInput(@SEC, 22, 0, 20)
$plus5min = GUICtrlCreateButton("5min", 33, 0, 33)
$plus1min = GUICtrlCreateButton("1min", 33, 0, 33)
GUISetState()

While 1
    $plus = 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $plus5min
            $plus = 5
            ContinueCase
        Case $plus1min
            $newdate = _DateAdd("n", $plus, _
                    GUICtrlRead($year) & "/" & _
                    GUICtrlRead($mon) & "/" & _
                    GUICtrlRead($day) & " " & _
                    GUICtrlRead($hour) & ":" & _
                    GUICtrlRead($min) & ":" & _
                    GUICtrlRead($sec))
            If @error Then Exit MsgBox(262144, "Debug " & @ScriptName, "@Error: " & @error & @LF & "@Extended: " & @extended & @LF & "@ScriptLineNumber: " & @ScriptLineNumber & @LF & "_DateAdd() failed. Invalid input. Try again...", 0)
;~          MsgBox(64 + 262144, " ", $newdate, 0)
            $aDate = StringSplit($newdate, "/ :", 0)
;~          _ArrayDisplay($aDate)
            GUICtrlSetData($year, $aDate[1])
            GUICtrlSetData($mon, $aDate[2])
            GUICtrlSetData($day, $aDate[3])
            GUICtrlSetData($hour, $aDate[4])
            GUICtrlSetData($min, $aDate[5])
            GUICtrlSetData($sec, $aDate[6])
    EndSwitch
WEnd
Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

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