Older Version Newer Version

Alyce Alyce Nov 4, 2006

[[map|Lesson Map]] | [[0304|Next > Define Variables]]

= Echo the Input=

You asked for the user's name with:

[[code]]
input "What is your name? "; name$
[[code]]

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:

[[code]]
print name$
[[code]]

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):

[[code]]
input "What is your name? "; name$
print name$
[[code]]

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.

[[map|Lesson Map]] | [[0304|Next > Define Variables]]