[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Simple HH:MM:SS counter

Posted on 2003-11-14
6
Medium Priority
?
359 Views
Last Modified: 2010-04-05
How can I write a simple HH:MM:SS counter to time a procedures duration ?. The counter does not have to be very accurate just a start/stop counter to the nearest second or so. I would like a coded answer without using any components.

Thanks
Paul.
0
Comment
Question by:pr_wainwright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 2

Expert Comment

by:DeNavigator
ID: 9749186
procedure ProcedureName;
var
  TotalTime, StartTime: Cardinal;
begin
  StartTime := GetTickCount;
  // Here your code
  TotalTime := GetTickCount - StartTime;
  ShowMessage('It took ' + IntToStr(TotalTime) + ' msec.');
end;

0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 9749505
DeNavigator,
 Sorry, maybe my question was not very clear. I was hoping for say a TLabel caption to update in real time as the procedure executed e.g. '00:00:01' - '00:00:02'... etc.

Thanks
Paul.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 500 total points
ID: 9749566
Drag a TLabel and a TTimer onto your form. Then the following code will update the label with the time.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
            { Public declarations }
            Clock : integer;
      end;

var
      Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
      Inc(Clock);
      Label1.Caption := Format('%2.2d:%2.2d:%2.2d', [(Clock div 3600) mod 24, (Clock div 60) mod 60, Clock mod 60]);
end;

end.


Geoff M.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Expert Comment

by:gmayo
ID: 9749574
PS - if you are doing a processor-intensive procedure, you may want to call Application.ProcessMessages every now and again (at *least* once per second) to allow the timer to trigger.

Geoff M.
0
 
LVL 2

Expert Comment

by:DeNavigator
ID: 9749678
I created once a timer-component. If you like the code just post a comment with your email and i'll send you the sources. if you understan dutch you could have a look at this: http://www.nldelphi.com/cgi-bin/articles.exe/ShowArticle?ID=10257
I wrote this article and is describes the stopwatch component. (in dutch :) )
0
 
LVL 1

Author Comment

by:pr_wainwright
ID: 9750016
Geoff,
        Your code is exactly what I required. Simple & works perfectly.

Thanks
Paul.

P.S. Thanks also to DeNavigator.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question