KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Displaying an updating time on an input form
PRODUCT: 4D | VERSION: | PLATFORM:
Published On: July 16, 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.

o 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 'timeCurrentTime'.

- Add the following code to your Form Method:

Case of
 : (Form event=On Load )
 timeCurrentTime:=Current time
 SET TIMER(60)
 : (Form event=On Timer )
 timeCurrentTime:=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.
Cut and Paste the following code example into your
own 4D project