Learn R Programming

gWidgets2 (version 1.0-9)

gtimer: Basic timer widget

Description

Calls FUN every ms/1000 seconds. A timer is stopped through its stop_timer method which is called using OO style: obj$stop_timer().

Usage

gtimer(
  ms,
  FUN,
  data = NULL,
  one.shot = FALSE,
  start = TRUE,
  toolkit = guiToolkit()
)

.gtimer(toolkit, ms, FUN, data = NULL, one.shot = FALSE, start = TRUE)

Arguments

ms

interval in milliseconds

FUN

FUnction to call. Has one argument, data passed in

data

passed to function

one.shot

logical. If TRUE, called just once, else repeats

start

logical. If FALSE, started by start_timer OO method. (Call obj$start_time()).

toolkit

gui toolkit to dispatch into

Examples

Run this code
# NOT RUN {
i <- 0
FUN <- function(data) {i <<- i + 1; if(i > 10) a$stop_timer(); print(i)}
a <- gtimer(1000, FUN)
##
## a one shot timer is run only once
FUN <- function(data) message("Okay, I can breathe now")
hold_breath <- gtimer(1000*60, FUN, one.shot=TRUE)
# }

Run the code above in your browser using DataLab