useraction {RandomFields}R Documentation

Set input behaviour

Description

The functions store values that influence the behaviour of Locator and Readline

Usage

useraction(action=c("none", "start.register", "continue.register",
                    "replay", "endless", "delete"),
                    sleep, wait, PrintLevel, actionlist)
putactions(l)

Arguments

action string of the following values
‘"none"’
the behaviour of Readline and Locator is that of readline and locator, respectively. The values are not stored.
‘"start.register"’
the behaviour of Readline and Locator is that of readline and locator, respectively. The current list of stored values is deleted and new inputs by Readline and Locator are stored.
‘"continue.register"’
the behaviour of Readline and Locator is that of readline and locator, respectively. The current list of stored values is continued with inputs from Readline and Locator.
‘"replay"’
Locator and Readline do not get the data from the mouse or terminal, but read them from the stored list. If the end of storage list is reached, the user is informed and the action is switched to “none”.
‘"endless"’
similar to ‘"replay"’, but storage list is looped.
‘"delete"’
The current list of stored values is deleted and action is set to “none”
actionlist list of stored values by Readline and Locator
sleep sleeping time before the blinking starts (replay mode of Locator); value is kept until explicit changing; starting value: 2.5
wait regulated the blinking speed of the characters (Locator) and of the speed of appearance of characters (Readline); value is kept until explicit changing; starting value: 0.1
PrintLevel if Printlevel>1 and Readline or Locator is in replay mode then the current pointer position within the storage list and the tracing information (if any) is shown. The value is kept until explicit changing; starting value: 0
l list of all parameters relevant to the behaviour of Readline and Locator.

Details

The function putactions restores the state taken by getactions.

Concerning the function useraction, the parameter action must be given. If any of the other parameters is not given, its current value is kept. If action="start.register" or action="delete", the value of actionlist is ignored.

If replaying, Readline shows the input values on the screen and Locator shows blinking characters as side effects.

Value

useraction returns NULL.
putactions returns invisibly the state before the new state is set.

Author(s)

Martin Schlather, martin.schlather@math.uni-goettingen.de http://www.stochastik.math.uni-goettingen.de/institute

See Also

eval.parameters, getactions, Locator, Readline,

Examples

sample.interaction <- function(read.r2=TRUE, type="p", pch=16) {
  r1 <- Readline(prompt="first input: ")
  r2 <- if (read.r2) Readline(prompt="second input: ", info="2nd input")
  else " -- no input  -- "
  cat("Mark some points with the right mouse key, then leave with the left mouse key\n")
  do.call(getOption("device"), list())
  plot(Inf, Inf, xlim=c(-1,1), ylim=c(-1,1), xlab="", ylab="")
  l <- Locator(100, info="locator input", type=type, pch=pch)
  r3 <- Readline(prompt="third input: ", info="last input")
  return(list(r1=r1, r2=r2, l=l, r3=r3))
}

#########################
## user terminal input ##
#########################
{
  useraction("start.register")
  str(sample.interaction())
  str(l <- getactionlist())
}

#################
## just replay ##
#################
useraction("replay", sleep=2, wait=interactive() * 0.2 * 5,
           PrintLevel=2, actionlist=l)
str(sample.interaction(type="l"))

##############################################
## modify first the input list, then replay ##
##############################################
l2 <- l[-2]
l2[[1]] <- list("some other words", info="changed input")
str(l2)
useraction("replay", sleep=1, wait=interactive() * 0.05,
           PrintLevel=0, l2) 
str(sample.interaction(read.r2=FALSE, type="o")) # input now from l2
Readline(prompt="new input: ", info="?!") # switch to terminal
##                                                since end of stored list
# str(getactionlist())    # new input has not been not stored ...

####################################################
## use of the two lists, l and l2, in a mixed way ##
####################################################
useraction("replay", sleep=2, wait=interactive() * 0.05,
           PrintLevel=0, actionlist=l)
Readline(prompt="first input of 1: ")
dump <- getactions()
useraction("replay", sleep=0.5, wait=interactive() * 0.05,
           PrintLevel=0, actionlist=l2)
Readline(prompt="first input of 2: ")
dump2 <- putactions(dump)
Readline(prompt="second input of 1: ")
## locator call reading from list 1:
plot(Inf, Inf, xlim=c(-1,1), ylim=c(-1,1), xlab="", ylab="")
Locator(100, info="locator input", type="p")
dump <- putactions(dump2)
##locator call reading from list 2:
Locator(100, info="locator input", type="p", pch=20, col="blue")
Readline(prompt="last input of 2: ")
putactions(dump)
Readline(prompt="last input of 1: ")

#####################################################
## see help("eval.parameters") for another example ##
#####################################################


[Package RandomFields version 1.3.41 Index]