TURBO PASCAL |
Новости
|
44: How can I put a running clock into my Turbo Pascal program?A: We are not speaking of a stand-alone TSR-clock (which is a different task), but considering a clock that continuously displays the time in some part of the output screen of your Turbo Pascal program. You might first want to read the earlier items about ReadKey usages if you are not familiar with it (you probably are, because you would not pose this advanced question if you were a novice). The items are the unlikely "How do I disable or capture the break key in Turbo Pascal?" and "How can I read input without echoing to the screen?" The general idea is to make the body of the program a repeat until loop using ReadKey for input and updating the clock display at suitable junctions within the loop. The scheme is thus something like the following. procedure showtime; begin { if the second has changed, write the time } end; : repeat { do whatever } showtime; if KeyPressed then case ReadKey of { whatever } { exit rules } end; showtime; : showtime; until false; One trick of the trade is that you must not update your clock each time the clock routine is encountered. You should test if the second has changed, and update only then. Else you are liable to get an annoying flicker in your clock. |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |