Jump to content

Time Calculator


DaProgrammer
 Share

Recommended Posts

Ever needed to Calculate how much time are all 3 movies together and started to multiply the hours *3600 and the minutes *60, well no more.

I present to you the time calculator.

Opt("GUIOnEventMode",1)
GuiCreate("KJ's TC", 130, 70,-1, -1)
GUISetOnEvent(-3,"Exitt")

GUICtrlCreateLabel(":",33,12,15,15)
GUICtrlCreateLabel(":",63,12,15,15)
GUICtrlCreateLabel(":",33,42,15,15)
GUICtrlCreateLabel(":",63,42,15,15)
$Input_h1 = GuiCtrlCreateInput("", 10, 10, 20, 20)
$Input_m1 = GuiCtrlCreateInput("", 40, 10, 20, 20)
$Input_s1 = GuiCtrlCreateInput("", 70, 10, 20, 20)
$Input_h2 = GuiCtrlCreateInput("", 10, 40, 20, 20)
$Input_m2 = GuiCtrlCreateInput("", 40, 40, 20, 20)
$Input_s2 = GuiCtrlCreateInput("", 70, 40, 20, 20)
$Button_a = GuiCtrlCreateButton("+", 100, 5, 15, 15)
$Button_s = GuiCtrlCreateButton("-", 100, 25, 15, 15)
$Button_r = GuiCtrlCreateButton("R", 100, 45, 15, 15)

GUICtrlSetOnEvent($Button_a,"Add")
GUICtrlSetOnEvent($Button_s,"Subtract")
GUICtrlSetOnEvent($Button_r,"Reset")

GuiSetState()
While 1
Sleep(1000)
WEnd

Func Add()
    GUICtrlSetData($Input_s1,GUICtrlRead($Input_s1)+GUICtrlRead($Input_s2))
    GUICtrlSetData($Input_s2,"")
    While GUICtrlRead($Input_s1)>=60
        GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)+1)
        GUICtrlSetData($Input_s1,GUICtrlRead($Input_s1)-60)
    WEnd
    
    GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)+GUICtrlRead($Input_m2))
    GUICtrlSetData($Input_m2,"")
    While GUICtrlRead($Input_m1)>=60
        GUICtrlSetData($Input_h1,GUICtrlRead($Input_h1)+1)
        GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)-60)
    WEnd
    
    GUICtrlSetData($Input_h1,GUICtrlRead($Input_h1)+GUICtrlRead($Input_h2))
    GUICtrlSetData($Input_h2,"")
EndFunc

Func Subtract()
    GUICtrlSetData($Input_s1,GUICtrlRead($Input_s1)-GUICtrlRead($Input_s2))
    GUICtrlSetData($Input_s2,"")
    While GUICtrlRead($Input_s1)<0
        GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)-1)
        GUICtrlSetData($Input_s1,GUICtrlRead($Input_s1)+60)
    WEnd
    
    GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)-GUICtrlRead($Input_m2))
    GUICtrlSetData($Input_m2,"")
    While GUICtrlRead($Input_m1)<0
        GUICtrlSetData($Input_h1,GUICtrlRead($Input_h1)-1)
        GUICtrlSetData($Input_m1,GUICtrlRead($Input_m1)+60)
    WEnd
    
    GUICtrlSetData($Input_h1,GUICtrlRead($Input_h1)-GUICtrlRead($Input_h2))
    GUICtrlSetData($Input_h2,"")
EndFunc

Func Reset()
    GUICtrlSetData($Input_h1,"")
    GUICtrlSetData($Input_m1,"")
    GUICtrlSetData($Input_s1,"")
    GUICtrlSetData($Input_h2,"")
    GUICtrlSetData($Input_m2,"")
    GUICtrlSetData($Input_s2,"")
EndFunc

Func Exitt()
    Exit
EndFunc
Edited by DaProgrammer
Link to comment
Share on other sites

Sweet! Nice improvements... Did you build this for another project or just like me kinda wandering around doing a bit here and there for fun?

i made a couple of projects, some of which u can find by following my sig. but mainly thinking of ideas for a big project and plying around in the meantime.

Link to comment
Share on other sites

Nice, I like the simplicity of it.

One suggestion, modify the tray icon or get rid of it.

its a tool to work with and an idea for others to implement i didnt bother to make it pretty and stuff, if u want pretty follow my sig and download the alarm clock its what u might call a finished product, published on Download.com(C.Net)

Link to comment
Share on other sites

  • 2 weeks later...

:) Have'nt tried yours yet, but here's a version I quickly knocked up some time ago

Time Calculator v1.5

Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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