Solved

Timer/Counter thread

Posted on 1998-03-10
7
206 Views
Last Modified: 2010-04-06
I'm trying to create a counter program that counts the time between the moment you press a start and a stop button (and updates it every second in a TLabel.Caption). Thus far i created a threaded label that updates the caption to the current time every second. I can't figure out how to put in the time difference (how do i send the starting time as a parameter). Does anybody have an idea how to solve this (or better: do you have an example program?)
0
Comment
Question by:scheiko
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1360391
Yo scheiko,

????

// ----------------- GetSystemTime -------------------------------

var
  st : TSystemTime;
begin
  GetSystemTime( st );
  // or GetLocalTime( st );

  // now you can use the st structure to get time info.
end;

So. Call this in the beginning and you got your beginning time. Then do all the stuff you want to do with it. By the way you can also get the time with the function Now.

regards, Zif.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1360392
scheiko, maybe an enhanced threaded timer will do the job, uh?

freeware, but I can't remember where I found it, so post your email

My email: bosism@netvision.net.il

Good luck!
0
 

Author Comment

by:scheiko
ID: 1360393
Thanks guys, but...

The calculation of the time difference is not so much the problem. The real trouble is continuously updating the time difference. My application registrates the startingtime at the moment a button is pressed. The thread reads the current time (Now) and displays it (every second) in a TLabel.Caption. How do i pass the starting time to the (unit with the TLabel.Caption) timer. I'll place the source on ftp://scheiko.chem.ruu.nl user anonymous so you can see what i mean. It'll be there until tomorrow 12:00 pm GMT.

Thanks again!
Scheiko
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1360394
Sorry, but seeing your code I still don't understand what you just need?

To pass a variable to a unit : there are several ways, one is making in the public declaration the following :

 StartTimeValue : TDateTime read fStartTimeValue write fStartTimeValue

 in the private section write : fStartTimeValue : TDateTime

Now when you want to read this value into a variable do this :

 Inside the unit : TimerStartedAt := fStartTimer
 Outside the unit : TimerStartedAt := Unit1.StartTimeValue

Now when you want to write a value to this variable do this :
 
 Inside the unit :  fStartTimer := Time
 OutSide the unit : Unit1.StartTimeValue := Time

If this isn't what you want please explain in another way.

Met vriendelijke groeten Zif.

0
 

Author Comment

by:scheiko
ID: 1360395
Dear Zifnab,

Thanks alot, i think you gave me the perfect hunch.

Ajuu,
Scheiko
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1360396
Hi scheiko,

If your answer is answered lets remove this question from the list and grade it.
If you still need some advice, just give a comment.

Regards, Zif.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1360397
scheiko, if you still have problems then the timer I have is just what you need.

Post your email...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 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