Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2023.1.0 - 日本語


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 — トグルボタンにより選択を行う対話的Xwindow
  • x_matrix — Edits a matrix and waits for validation (modal)
  • evstr — 式を評価する

History

バージョン記述
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 >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon May 22 12:43:16 CEST 2023