Kbase 13612: Example of implementing clock on a window in Version 7
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  5/10/1998 |
|
Example of implementing clock on a window in Version 7
This knowledgebase describes one idea for implementing a clock on a
window in Version 7 PROGRESS.
The idea is to have a window with one fill-in widget to serve as
the clock. It is advisable to make this fill-in VIEW-AS TEXT (by
making sure it is displayed but not enabled for user input.)
One other feature is a logical variable called GET-OUT which serves
as a way for the program to get out of the timer loop and exit the
program. Define it as follows, with initial value FALSE:
DEFINE VARIABLE get-out AS LOGICAL INITIAL FALSE.
To implement the timer, write a loop around the WAIT-FOR that is
similar to the following:
RUN enable_UI.
DO WHILE TRUE:
fill-in-1:SCREEN-VALUE = STRING(TIME, "HH:MM:SS").
WAIT-FOR U1 OF CURRENT-WINDOW PAUSE 1.
IF get-out THEN LEAVE.
END.
RUN disable_UI.
The way to "break out" of the loop is to set get-out to be true.
One event to take into account with this is WINDOW-CLOSE, since as
it stands the WAIT-FOR above is waiting for a "dummy" programmer
event, U1, and not the usual WINDOW-CLOSE. So, in order to assure
that WINDOW-CLOSE will work properly, you need to make sure a
trigger is defined for the WINDOW-CLOSE event:
ON WINDOW-CLOSE OF WINDOW-1 DO:
get-out = TRUE.
RETURN NO-APPLY.
END.
The RETURN NO-APPLY assures that a beep won't occur when the user
closes the window using a ventilator.
One other way that the logical variable get-out could be set is as the
result of an "Exit" button:
ON "CHOOSE" OF btn_exit DO:
get-out = TRUE.
END.
Other events can set get-out = TRUE as desired.
One important note: this example is but a simplification, and as it
stands is also a rewrite of the Main Block code that is used as the
UIB default. You may wish to write further code to make sure the
blocking properties (and undo properties in 7.3) of the UIB are
retained.
Progress Software Technical Support Note # 13612