What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » HELP - Seconds to hours!

HELP - Seconds to hours!
Author: Message:
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. Huh?  HELP - Seconds to hours!
Javascript code:
var Counting = false;
var Paused = false;
 
var CountWindow;
var CountWndOpen = false;
 
var AdjustWindow;
var AdjustWndOpen = false;
 
var Hours = 0;
var Minutes = 0;
var Seconds = 0;
var Milliseconds = 0;
var TotalTime = 0;
 
var Add0S;
var Add0M;
var Add0H;
 
// left some out otherwise this post would be really long...
 
function OnEvent_Timer(TimerId)
{
    if (TimerId = "RefreshTime")
    {
        Milliseconds = Milliseconds + 1;
        if (Milliseconds == 10)
        {
            Milliseconds = 0;
            Seconds = Seconds + 1;
            if (Seconds == 60)
            {
                Seconds = 0;
                Minutes = Minutes + 1;
                if (Minutes = 60)
                {
                    Minutes = 0;
                    Hours = Hours + 1;
                }
            }
        }
        TotalTime = TotalTime + 1;
        if (Seconds < 10)
        {
            Add0S = "0";
        }
        else
        {
            Add0S = "";
        }
        if (Minutes < 10)
        {
            Add0M = "0";
        }
        else
        {
            Add0M = "";
        }
        if (Hours < 10)
        {
            Add0H = "0";
        }
        else
        {
            Add0H = "";
        }
        if (CountWndOpen)
        {
            CountWindow.SetControlText("TimeElapsed", "Time elapsed: " + Add0H + Hours + ":" + Add0M + Minutes + ":" + Add0S + Seconds + "." + Milliseconds + " (" + TotalTime + "ms)");
        }
        if (AdjustWndOpen)
        {
            AdjustWindow.SetControlText("Hours", Add0H + Hours);
            AdjustWindow.SetControlText("Minutes", Add0M + Minutes);
            AdjustWindow.SetControlText("Seconds", Add0S + Seconds);
            AdjustWindow.SetControlText("NewTime", "New time: " + Add0H + Hours + ":" + Add0M + Minutes + ":" + Add0S + Seconds + "." + Milliseconds + " (" + TotalTime + "ms)");
            try
            {
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("HoursAdd"), 1);
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("HoursSubtract"), 1);
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("MinutesAdd"), 1);
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("MinutesSubtract"), 1);
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("SecondsAdd"), 1);
                Interop.Call("User32", "EnableWindow", AdjustWindow.GetControlHandle("SecondsSubtract"), 1);
            }
            catch (error)
            {
            }
        }
        MsgPlus.AddTimer("RefreshTime", 100);
    }
}


XML code:
<Interfaces xmlns="urn:msgplus:interface" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:msgplus:interface PlusInterface.xsd">
 
<Window Id="WndCounter" Version="1">
 
    <Attributes>
        <Caption>Plus! Counter</Caption>
    </Attributes>
 
    <TitleBar>
        <Title>
            <Prefix>Image</Prefix>
            <Text>Plus! Counter</Text>
        </Title>
    </TitleBar>
 
    <Position Width="157" Height="48"/>
 
    <DialogTmpl/>
 
    <Elements>
        <Element xsi:type="ImageElement" Id="GLoad">
            <Position Top="0" Left="2"/>
            <Image><Name>icon-update</Name></Image>
        </Element>
    </Elements>
 
    <Controls>
        <Control xsi:type="StaticControl" Id="TimeElapsed">
            <Position Left="30" Top="-2" Width="121"/>
            <Caption>Time elapsed: 00:00:00:0 (0ms)</Caption>
        </Control>
        <Control xsi:type="LinkControl" Id="Pause">
            <Position Left="30" Top="8" Width="21"/>
            <Caption>Pause</Caption>
        </Control>
        <Control xsi:type="LinkControl" Id="Resume">
            <Position Left="53" Top="8" Width="27"/>
            <Caption>Resume</Caption>
        </Control>
        <Control xsi:type="LinkControl" Id="Stop">
            <Position Left="82" Top="8" Width="16"/>
            <Caption>Stop</Caption>
        </Control>
        <Control xsi:type="LinkControl" Id="Adjust">
            <Position Left="100" Top="8" Width="46"/>
            <Caption>Adjust (BETA)</Caption>
        </Control>
    </Controls>
</Window>
 
<!-- don't need the other two windows... -->
 
</Interfaces>


Every 100 milliseconds, the refresh timer is called and adds 1 to the milliseconds variable.  If that reaches 10, it resets and 1 is added to the seconds variable.  If that reaches 60, that then resets and 1 is added to the minutes variable.  And the same happens to the hours variable.  The trouble is, after 59 seconds, it adds 1 to the hours, not to the minutes.  And I have no idea why!  :S

.plsc File Attachment: Plus! Counter.plsc (4.21 KB)
This file has been downloaded 65 time(s).
05-17-2009 11:48 AM
Profile E-Mail PM Find Quote Report
NanaFreak
Scripting Contest Winner
*****


Posts: 1476
Reputation: 53
32 / Male / Flag
Joined: Jul 2006
RE: HELP - Seconds to hours!
Javascript code:
if (Milliseconds == 10)
        {
            Milliseconds = 0;
            Seconds = Seconds + 1;
            if (Seconds == 60)
            {
                Seconds = 0;
                Minutes = Minutes + 1;
                if (Minutes = 60)                {
                    Minutes = 0;
                    Hours = Hours + 1;
                }
            }
        }


higlighted line should be

Javascript code:
if (Minutes == 60)


;)

This post was edited on 05-17-2009 at 12:05 PM by NanaFreak.
05-17-2009 12:04 PM
Profile PM Find Quote Report
whiz
Senior Member
****


Posts: 568
Reputation: 8
– / – / Flag
Joined: Nov 2008
O.P. RE: HELP - Seconds to hours!
Ah...  thanks!  :)
05-17-2009 12:31 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On