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

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.