selectCore {goCluster} | R Documentation

## A menu function

### Description

The function generates a generic menu that will return the choice of the user.

### Usage

    selectCore(message,
    convert = function(X) X,
    check = function(X) TRUE,
    options = NULL,
    optflag = TRUE,
    error = function(X) return("Invalid choice!"),
    ...
    )
    selectCorePlain(message,
    convert = function(X) X,
    check = function(X) TRUE,
    options = NULL,
    optflag = TRUE,
    error = function(X) return("Invalid choice!"),
    ...
    )
    selectCoreTk(message,
    convert = function(X) X,
    check = function(X) TRUE,
    options = NULL,
    optflag = TRUE,
    error = function(X) return("Invalid choice!"),
    ...
    )

### Arguments

`message` | The informational message that will be shown together with the menu.
`convert` | A function that converts the user input to a desired format or class type.
`check` | A function that checks the user input for validity.
`options` | The available options as character vector, if any.
`optflag` | Is the user allowed to select several options or only one?
`error` | The function that should be executed in case of an error. This should deliver a message that is useful to the user.
`...` | Additional arguments for the convert, check and error functions.

### Details

`selectCore` is a function that provides a generic menu. This can either be a simple textual menu or a graphical version depending on the setting of the option `goCluster.useTk`. You can use `option(goCluster.useTk=1)` to activate the graphical menu. `selectCore` will then dispatch the function call to the Tk version of the function instead of the textual version. The textual menu is the default. The function needs a message that should be displayed to the user, a function to convert the user input to a desired format and another function to check the validity of the user input. Finally a set of options that should be displayed to the user as a numbered list can be specified as a character vector. If `convert` is not specified, the user input will be used as given (string format) and if `check` is left unspecified, the check will always return TRUE.

### Value

The choice of the user in the format returned by the convert function.

### Author(s)

Gunnar Wrobel, http://www.gunnarwrobel.de.

### See Also

`selectOption`, `selectDouble`, `selectNumber`.

### Examples

    if(interactive()){
    ## This example can only be run in an interactive mode
    option(goCluster.useTk=0)

    selectCore("Please choose a number between 0 and 10",convert=function(X) as.integer(X), check=function(X) (X > 0 & X < 10))

    option(goCluster.useTk=1)

    selectCore("Please choose a number between 0 and 10",convert=function(X) as.integer(X), check=function(X) (X > 0 & X < 10))
    }

[Package goCluster version 1.0.3 Index]