Older Version Newer Version

Alyce Alyce Nov 4, 2006

[[map|Lesson Map]] | [[0306|Next > Add Comments]]

= Print Text and Variables=

In the [[0305|previous lesson]] you asked the user to type his name, then you printed it back out for him. 

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

You can make this seem a little more friendly by adding a message when you print the **name$** variable. 

You can "add" two pieces of text together by using the **+** symbol. It works whether the text is in quotation marks or contained in string variables. Here is some code that uses **+** to display two separate pieces of text.

[[code]]
print "Liberty " + "BASIC"
[[code]]

It's just that easy! Now you can greet your program's user by name. Type this code into the Liberty BASIC editor and run it to see the result.

[[code]]
input "What is your name? "; name$
print "It's nice to meet you, " + name$
[[code]]

Liberty BASIC also lets you use the semicolon symbol to add pieces of text together. The semicolon looks like this. **;** It works in exactly the same way as the **+** symbol. This code does the same thing as the previous code.

[[code]]
input "What is your name? "; name$
print "It's nice to meet you, " ; name$
[[code]]

[[map|Lesson Map]] | [[0306|Next > Add Comments]]