Learn R Programming

svDialogs (version 0.9-50)

dlgInput: A simple input box

Description

Enter one (textual) value with this input box.

Usage

dlgInput(message = "Enter a value", default = "", ..., gui = .GUI)

## These should not be called directly
## S3 method for class 'gui':
dlgInput(message = "Enter a value", default = "", \dots, gui = .GUI)
## S3 method for class 'textCLI':
dlgInput(message = "Enter a value", default = "", \dots, gui = .GUI)
## S3 method for class 'nativeGUI':
dlgInput(message = "Enter a value", default = "", \dots, gui = .GUI)

Arguments

message
the message to display in the dialog box. Use \n for line break, or provide a vector of character strings, one for each line.
default
the default value in the text box. Single string or NULL.
...
pass further arguments to methods.
gui
the 'gui' object concerned by this dialog box.

Value

  • The modified 'gui' object is returned invisibly. The text entered by the user at the input box, or an empty string if the dialog box was cancelled can be obtained from gui$res (see example).

concept

GUI API dialog boxes

See Also

dlgMessage

Examples

Run this code
## Ask something...
user <- dlgInput("Who are you?", Sys.info()["user"])$res
if (!length(user)) { # The user clicked the 'cancel' button
    cat("OK, you prefer to stay anonymous!
")
} else {
    cat("Hello", user, "")
}

Run the code above in your browser using DataLab