RandomFields (version 2.0.71)

useraction: 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 [object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
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 unt
PrintLevel
if Printlevel>1 and Readline or Locator is in replay mode then the current pointer position within the storage list and
l
list of all parameters relevant to the behaviour of Readline and Locator.

Value

  • useraction returns NULL.

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

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.

See Also

eval.parameters, getactions, Locator, Readline,

Examples

Run this code
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
")
  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 ##
#####################################################

Run the code above in your browser using DataCamp Workspace