Tech Tip: Time Display
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: October 29, 1999
It may be useful to display the current time on an input form. In a
contact database, for example, it may be useful to know both the current
time and the time adjusted to the time zone at the contact’s location.
A new command and matching form event in 4D v6.5 make this much easier
than before.
- Create a non-enterable variable on your form. It is probably best
placed on the master page – page 0. Format the font, size and color as
desired. Use the Data Control tab of the Object Properties to format the
variable for a suitable time display. Give it a suitable name, such as:
time_CurrentTime - Add the following code to your Form Method:
Case of
: (Form event=On Load )
time_CurrentTime:=Current time
SET TIMER(60)
: (Form event=On Timer )
time_CurrentTime:=Current time
End case - When the form is loaded the value for the time display variable is
set. - The SET TIMER command generates an On Timer form event every 60 ticks – a tick is approximately 1/60th of a second.
- Each time this event is generated it updates the variable displaying
the time. In the Form Properties dialog, Events tab you need to enable the 'On Timer’ event, otherwise the form will not respond to it, and therefore not update the time.