Input

Input Introduction

Input is essential to every program, because if there was no user-input, then the program would do the same thing every time. To prevent this, we gave user input.

Get Statement

In Turing, to get information from the user, we use the get command like so:

get <VariableName>

This will wait for the user to input a value of the same type that the variable is. If the types do not match, the program will crash. Because of this, it is important to specify what the user needs to input, like so:
put "Please Input A Number: "..
get iNumber

When you use the 'get' statement, you're telling the computer to put a user-inputted value into your variable bucket. This is one of two ways to assign a value to the variable. The other way is by using ' := '.

Getting More Information

If you need to get a string, but anticipate the user will enter a space (such as when you ask for their name), you can use:

get sFullName : *

By putting the " :* " after the 'get', you tell Turing to get everything, including spaces.
If you don't add the ' :* ' after the 'get', and the user enters spaces, then Turing will only get the first string before the spage.
E.g. I if you type
get sFullName

and the user enters
Mr. Mantas

then the value in sFullName will be "Mr.". To avoid this, use " :* " after your 'get' statement
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License