textinput

Interactive input of text

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

textinput(<prompt1>)
textinput(<prompt1>, x1, <prompt2>, x2, …)

Description

textinput allows interactive input of text.

textinput() displays the prompt "Please enter text:" and waits for input by the user. The input is converted to a character string, which is returned as the function's return value.

textinput(prompt1) uses the character string prompt1 instead of the default prompt "Please enter text:".

textinput( prompt1 x1) converts the input to a character string and assigns this string to the identifier or local variable x1. The default prompt is used, if no prompt string is specified.

Several input values can be read with a single textinput command. Each identifier in the sequence of arguments makes textinput return a prompt, waiting for input to be assigned to the identifier or variable. A character string preceeding the identifier or variable in the argument sequence replaces the default prompt. Cf. Example 3. Arguments that are neither prompt strings nor identifiers or variables are ignored.

The input may extend over several lines. In the output string, MuPAD® uses the character \n (carriage return) to separate lines.

Input characters with a leading \ are not interpreted as control characters, but as two separate characters.

The identifiers or variables x1 etc. may have values. These are overwritten by textinput.

Examples

Example 1

The default prompt is displayed, the input is converted to a character string and returned:

textinput()
Please enter text input: << myinput >> 

Example 2

A user-defined prompt is used, the input is assigned to the identifier x:

textinput("enter your name: ", x)
enter your name: << Turing >> 

x

delete x:

Example 3

If several values are to be read, separate prompts can be defined for each value:

textinput("She: ", hername, "He:  ", hisname)
She: << Bonnie >> He:  <<
Clyde >> 

hername, hisname

delete hername, hisname:

Parameters

prompt1, prompt2, …

Input prompts: character strings

x1, x2, …

identifiers or local variables

Return Values

Last input, converted to a character string.

Was this topic helpful?