Lesson Map | Next > Define Variables

Echo the Input


You asked for the user's name with:

input "What is your name? "; name$

The user replied. Now how do you get the name, the actual text, back out of the name$ variable so you can use it in the program?

You don't. The magic of variables is that you don't have to dig the information out of the variable to use it. You simply use the variable itself where you need it, and the data comes along by itself. To print the user's name, put the names$ variable into a print command:

print name$

The program will show the contents of name$ in the mainwin. Here's the whole program (copy and paste it into a new code window in LB Editor, or type it in yourself):

input "What is your name? "; name$
print name$

Some programming languages require you to define variables. Liberty BASIC does not have that requirement. Variables are defined as they are used, but there is one rule, so let's find out about that rule next.

Lesson Map | Next > Define Variables