Skip to main content
Version: Next

IDLE

IDLE

Does not require any parameters

Description

The IDLE command is designed only for use with the compiler. This command is only used in compiled databases in which user-defined methods are written so that no calls are made back to the 4D engine. For example, if a method has a For loop in which no 4D commands are executed, the loop could not be interrupted by a process installed with ON EVENT CALL, nor could a user switch to another application. In this case, you should insert IDLE to allow 4D to trap events. If you do not want any interruptions, omit IDLE.

Example

In the following example, the loop would never terminate in a compiled database without the call to IDLE:

  // Do Something Project Method
 ON EVENT CALL("EVENT METHOD")
 ◊vbWeStop:=False
 MESSAGE("Processing..."+Char(13)+"Type any key to interrupt...")
 Repeat
  // Do some processing that doesn’t involve a 4D command
    IDLE
 Until(◊vbWeStop)
 ON EVENT CALL("")

with:

  // EVENT METHOD Project Method
 If(Undefined(KeyCode))
    KeyCode:=0
 End if
 If(KeyCode#0)
    CONFIRM("Do you really want to stop this operation?")
    If(OK=1)
       ◊vbWeStop:=True
    End if
 End if

See also

Compiler Commands
ON EVENT CALL