getChoice {PBSmodelling} | R Documentation |
Choose One String Item from a List of Choices
Description
Prompts the user to choose one string item from a list of
choices displayed in a GUI. The simplest case getChoice()
yields TRUE
or FALSE
.
Usage
getChoice(choice=c("Yes","No"), question="Make a choice: ",
winname="getChoice", horizontal=TRUE, radio=FALSE,
qcolor="blue", gui=FALSE, quiet=FALSE)
Arguments
choice |
vector of strings from which to choose. |
question |
question or prompting statement. |
winname |
window name for the |
horizontal |
logical: if |
radio |
logical: if |
qcolor |
colour for |
gui |
logical: if |
quiet |
logical: if |
Details
The user's choice is stored in .PBSmod$options$getChoice
(or whatever winname
is supplied).
getChoice
generates an onClose
function that returns focus
to the calling window (if applicable) and prints out the choice.
Value
If called from a GUI (gui=TRUE
), no value is returned directly. Rather,
the choice is written to the PBS options workspace, accessible through
getPBSoptions("getChoice")
(or whatever winname
was supplied).
If called from a command line program (gui=FASLE
), the choice is returned
directly as a string scalar (e.g., answer <- getChoice(gui=F)
).
Note
Microsoft Windows users may experience difficulties switching focus between the R console and GUI windows. The latter frequently disappear from the screen and need to be reselected (either clicking on the task bar or pressing <Alt><Tab>. This issue can be resolved by switching from MDI to SDI mode. From the R console menu bar, select <Edit> and <GUI preferences>, then change the value of “single or multiple windows” to SDI.
Author(s)
Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC
See Also
chooseWinVal
, getWinVal
, setWinVal
Examples
## Not run:
#-- Example 1
local(envir=.PBSmodEnv,expr={
getChoice(c("Fame","Fortune","Health","Beauty","Lunch"),
"What do you want?",qcolor="red",gui=FALSE)
})
#-- Example 2
local(envir=.PBSmodEnv,expr={
getChoice(c("Homer Simpson","Wilberforce Humphries","Miss Marple","Gary Numan"),
"Who`s your idol?",horiz=FALSE,radio=TRUE,gui=FALSE)
})
## End(Not run)