Satimage Previous | Next
idle
Home Documentation Smile Smile's objects Scheduling tasks idle  
When Smile is idle, it sends periodically the idle event to those windows (to their scripts, actually) whose want idle property was set to true.

You handle idle with a handler such as:
on idle the_window
    -- do whatever suitable such as polling some process
    return 3
end idle
idle should return a number. This number specifies how much time, in seconds, Smile will wait before sending again idle to the window.

By default, an object's want idle property is set to false. You set it to true or false by script. In the example below, the idle calls are activated when the object gets created, and they are stopped if any error occurs in the idle handler.
on prepare the_window
    set want idle of the_window to true
end prepare
    
on idle the_window
    try
        -- perform some perioric task
        return 5 -- next call after 5 seconds
    on error s
        msg("An error occurred in the idle handler: " & s)
        set want idle of the_window to false
    end try
end idle
Copyright ©2008 Paris, Satimage