In this tutorial, we will learn the steps involved in getting user input in the Flowgorithm flowchart. We have discussed assigning a value to the variable using the Assign shape.
The general steps to take user input in the flowchart are as follows:
- Declare a variable to hold the user input data.
- Prompt the user with a user-friendly message.
- Save the user input to the variable.
To get a better understanding, we will design a flowchart to greet the user. The flowchart prompts the user to enter his/her name. The flowchart saves the user name and then greets the user.
Launch the Flowgorithm application. Declare a variable to hold the user name. Let’s name the variable as UserName. The data type of the variable should be String.
An Output shape is used to display data to the computer screen. We can use expressions and variables in the Output shape.
Add an Output shape to the flowchart. This is to prompt the user to enter the name. Left click on the flowchart arrow line and choose the Output shape.
Double click on the Output shape. Enter the user prompt message and click on OK button.
An Input shape reads the input from the keyboard and stores the data in the specified variable. Add an Input shape to store the user input and assign it to the variable declared in the first step. Double click on the Input shape and enter the variable name. Click on OK button.
Add another Output shape to display the greeting to the user. Let’s personalize the greeting and add the name of the user. Double click on the Output shape and enter the expression in the expression box.
“Hello , ” & UserName
& is the concatenation operator in Flowgorithm. The concatenation operator joins the strings and combines it as one String. For example, if the UserName variable holds “John” then the expression would be:
“Hello , ” & UserName -> “Hello , John”
Run the Flowchart
Click on the green play button in the Toolbar to run the flowchart.
- Green button to run the flowchart.
- User prompt displayed by the flowchart.
- User Input to the flowchart. (John)
- Flowchart output. ( Hello , John )