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(question="Make a choice: ", choice=c("Yes","No"),
          winname="getChoice", horizontal=TRUE, radio=FALSE,
          qcolor="blue", gui=TRUE, quiet=FALSE)

Arguments

question question or prompting statement
choice vector of strings from which to choose
winname window name for the getChoice GUI
horizontal if TRUE, display the choices horizontally, else vertically
radio if TRUE, display the choices as radio buttons, else as buttons
qcolor colour for question
gui if TRUE, getChoice is functional when called from a GUI, else it is functional from command line programs
quiet if TRUE, don't print the choice on the command line

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.

See Also

chooseWinVal, getWinVal, setWinVal

Examples

## Not run: 
#-- Example 1
getChoice("What do you want?", c("Fame","Fortune","Health",
   "Beauty","Lunch"),qcolor="red",gui=F)

#-- Example 2
getChoice("Who`s your daddy?",c("Homer Simpson","Pierre Trudeau",
   "Erik the Red"),horiz=F,radio=T,gui=F)
## End(Not run)

[Package PBSmodelling version 1.63 Index]