| useraction {RandomFields} | R Documentation |
The functions store values that influence the behaviour
of Locator and Readline
useraction(action=c("none", "start.register", "continue.register",
"replay", "endless", "delete"),
sleep, wait, PrintLevel, actionlist)
putactions(l)
action |
string of the following values
|
actionlist |
|
sleep |
sleeping time before the blinking starts (replay mode of
|
wait |
regulated the blinking speed of the characters
( |
PrintLevel |
if |
l |
list of all parameters relevant to the behaviour of
|
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.
useraction returns NULL.
putactions returns invisibly the state before the new state is set.
Martin Schlather, martin.schlather@math.uni-goettingen.de http://www.stochastik.math.uni-goettingen.de/~schlather
eval.parameters,
getactions,
Locator,
Readline,
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))
}
## Not run:
#########################
## 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 ##
#####################################################
## End(Not run)