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 
- without 
 
Description
x = input(message)
- prints the 
messageon a new line; - sets the caret at the message's end;
 - waits for a direct literal 
keyboard_inputof any length, + enter.keyboard_inputmust be a valid Scilab expression provided on the current line, without continuation mark...keyboard_inputcan include extended UTF-8 characters. - tries to evaluate 
x = evstr(k_input):- If it succeeds, 
xis output. - Otherwise: an error is displayed, and the user is prompted again until a valid Scilab expression is entered.
 
 - If it succeeds, 
 
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 — Dialog for interactive multi-lines input.
 - x_mdialog — Dialog for interactive vector/matrix input.
 - x_choose — interactive window choice (modal dialog)
 - x_choices — interactive Xwindow choices through toggle buttons
 - x_matrix — Edits a matrix and waits for validation (modal)
 - evstr — evaluates Scilab expressions and concatenates their results
 
History
| Version | Description | 
| 6.0.0 | In case where nothing is entered with the "string" option, input returns an empty string instead of a space.  | 
| Report an issue | ||
| << diary | Console | lines >> |