Lesson Map | Next > Add Comments

Print Text and Variables


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

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

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.

print "Liberty " + "BASIC"

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.

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

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.

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

Lesson Map | Next > Add Comments