SET TIMER

4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next

version 6.5


SET TIMER (tickCount)

ParameterTypeDescription
tickCountLongintTickcount or
-1=Trigger as soon as possible

Description

The SET TIMER command allows you to activate the On Timer form event and to set, for the current process, the number of ticks elapsed between each On Timer form event.

Note: For more information about this new form event, please refer to the description of the command Form event.

If this command is called in a context in which it is not displaying a form, it will have no effect.

If you pass -1 in the tickCount parameter, the command will activate the On Timer form event "as soon as possible", in other words, as soon as the 4D application hands over control to the event manager. More particularly, this means that you can make sure that a form is completely displayed before beginning processing (application fluidity).

Web server note: 4D's Web server can take advantage of this command as well as the On Timer form event to resend 4D forms. This feature allows you to obtain HTML pages updated in "real time" while saving bandwidth. Actually, updating a form in this case is not automatic; you must call the REDRAW command. You can then optimize the system by calling REDRAW only when the data has been modified.

Only browsers that interpret JavaScript allow you to automatically redraw pages. The laps defined by SET TIMER will be used by the browser and by the timeout of the Web process. The laps must be a few seconds (5 being a practical value). For more information, please refer to the second example shown below.

To procedurally disable the triggering of the On Timer form event, call SET TIMER again and pass 0 in tickCount.

Examples

1. Let's imagine that you want, when a form is displayed on screen, the computer to beep every three seconds. To do so, write the following form method:

   If (Form event=On Load)
      SET TIMER(60*3)
   End if 

   If (Form event=On Timer)
      BEEP
   End if

2. Let us imagine that you want your Web server to update a 4D form displayed on the Web browser every five seconds. To do so, write the following form method:

   If (Form event=On Load)
      SET TIMER(60*5)
   End if 

   If (Form event=On Timer)
      ...   `You can place a test here to see if the data is being modified and to 
         `execute the following line only if this is true. 
      REDRAW ([MyTable])
   End if

See Also

Form event, REDRAW.


4D - Documentation   Français   English   German   Spanish   4D v11 SQL, Command Theme List   4D v11 SQL, Command Alphabetical List   4D v11 SQL, Constant Theme List   Back   Previous   Next