rp.timer: Creates a series of timed actions

View source: R/timer.r

rp.timerR Documentation

Creates a series of timed actions

Description

This creates an interval timer and allows the user to set the criteria to stop the timer.

Usage

rp.timer(panel, microseconds, action, where)

Arguments

panel

the panel which has some relevant variables.

microseconds

time between each call of action.

action

function to be executed on each timer tick.

where

a function which should return true or false, taking parameter panel. When false the loop will stop.

Details

This allows the user to setup an interval timer and the function to be called at each 'tick'.

Care should be taken when writing code to anticipate interactions with the panel while activity controlled by a timer is underway, as these interactions may cause changes in the state of the panel.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

See Also

rp.control

Examples

## Not run: 
  stopme <- function(panel) panel$count<=20
  callme <- function(panel) {
    print(panel$count)
    panel$count = panel$count+1
    panel
  } 
  panel <- rp.control(count=1)
  rp.timer(panel, 500, callme, stopme)

## End(Not run)

rpanel documentation built on Feb. 16, 2023, 10:37 p.m.

Related to rp.timer in rpanel...