PBSmodelling (version 2.68.8)

getChoice: 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)

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) ).

Arguments

choice

vector of strings from which to choose.

question

question or prompting statement.

winname

window name for the getChoice GUI.

horizontal

logical: if TRUE, display the choices horizontally, else vertically.

radio

logical: if TRUE, display the choices as radio buttons, else as buttons.

qcolor

colour for question.

gui

logical: if TRUE, getChoice is functional when called from a GUI, else it is functional from command line programs.

quiet

logical: if TRUE, don't print the choice on the command line.

Author

Rowan Haigh, Pacific Biological Station, Fisheries and Oceans Canada, Nanaimo BC

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.

See Also

chooseWinVal, getWinVal, setWinVal

Examples

Run this code
if (FALSE) {
#-- 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)
})
}

Run the code above in your browser using DataLab