Time Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Time Help

MetalSnakeMetalSnake Posts: 1Member
I'm trying to make a program where the user types in a number to set a timer to go off in the amount of time the person intended it to go off.
I've been trying to use the 'GetTime' procedure to help me do this, but it's just not working the way i want it to. Maybe someone more experienced in using Pascal (windows version) can help me out? Thanks!

Comments

  • zibadianzibadian Posts: 6,349Member
    : I'm trying to make a program where the user types in a number to set a timer to go off in the amount of time the person intended it to go off.
    : I've been trying to use the 'GetTime' procedure to help me do this, but it's just not working the way i want it to. Maybe someone more experienced in using Pascal (windows version) can help me out? Thanks!
    :
    You can use the GetTime() for that. After you have asked the user for the time, you need to enter a loop, in which you do 2 things:
    - check if there are messages from windows. This is necessary, or else windows will report the program as "not responding".
    - check if the current time is equal or exceeds the time set by the user.If this is true, then exit the loop.
    After the loop you can do whatever you want to do to alert the user.
    The method described above works if the user specifies a time to be alerted. If you want the user to set a time after he is alerted (example: alert me after 2 hours), then you need to calculate the time at which he will be alerted. This is luckily not difficult in Pascal, since the TDateTime type is a double, which counts the days from a certain zero-date. Thus to get the time at which to alert the user, simply get the current time and add the number of hours divided by 24 to it.
    I hope this is what you were looking for. I myself don't program much in windows Pascal, so I cannot give you the precise code.
Sign In or Register to comment.