input prompts the user for keyboard input

## Syntax

                x = input(message)
                x = input(message, "string")

## Arguments

message

  character string: the inline prompting message. Extended UTF-8 characters are supported.

"string"

  optional flag, to return the input as is, as a literal string in `x`.

x

  - without `"string"`: `x = evstr(keyboard_input)`
  - With "string": `x = keyboard_input`

## Description

x = input(message)

- prints the `message` on a new line;
- sets the caret at the message's end;
- waits for a direct literal `keyboard_input` of any length, + enter. `keyboard_input` must be a valid Scilab expression provided on the current line, without continuation mark `..`. `keyboard_input` can include extended UTF-8 characters.
- tries to evaluate `x = evstr(k_input)` :
  - If it succeeds, `x` is output.
  - Otherwise: an error is displayed, and the user is prompted again until a valid Scilab expression is entered.

If `keyboard_input` is empty or made of blanks, `x` is set to `[]`.

x = input(message, "string") always sets `x` to the literal `keyboard_input` considered as a string, possibly empty `""`.

## Examples

    maxIter = input("Max number of iterations: ") // enter 300

    δ = 1e-6;
    tol = input("Tolerance: ")   // enter nothing or blanks

    tol = input("Tolerance: ")   // enter 7*δ

    f = input("Function: ");     // enter sin
    f == sin
    f(5)

    s = "ABC";
    r = input("Expression: ")    // enter s + "D"

    res = input("Invalid expression: ")  // enter  s/4

    --> maxIter = input("Max number of iterations: ") // enter 300
    Max number of iterations: 300
     maxIter  =
       300.

    --> δ = 1e-6;
    --> tol = input("Tolerance: ")   // | = caret before enter
    Tolerance:     |
     tol  =
        []

    --> tol = input("Tolerance: ")   // enter 7*δ
    Tolerance: 7*δ
     tol  =
       0.000007

    --> f = input("Function: ");     // enter sin
    Function: sin
    --> f == sin
     ans  =
      T
    --> f(5)
     ans  =
      -0.9589243

    --> s = "ABC";
    --> r = input("Expression: ")    // enter s + "D"
    Expression: s + "D"
     r  =
      "ABCD"

    --> res = input("Invalid expression: ")  // enter  s/4
    Invalid expression: s / 4
    Undefined operation for the given operands.
    check or define function %c_r_s for overloading.

    Invalid expression:

The `"string"` option returns the input string as is, with leading and trailing white spaces. Extended characters are accepted:

    x = input("Prénom (surname): ","string")      //  enter André

    --> x = input("Prénom (surname): ","string")  // | = caret before enter
    Prénom (surname):   André   |
     x  =
      "  André   "

## See also

- x_dialog
- x_mdialog
- x_choose
- x_choices
- x_matrix
- evstr

## History

6.0.0

In case where nothing is entered with the "string" option, input returns an empty string instead of a space.