Lesson Map | Next > Mainwin Summary

Add Comments


So far, every word you've typed into your programs has been an instruction for Liberty BASIC. You can also add notes for yourself that Liberty BASIC ignores. You might want to give yourself a note to remind you what the code does. You might want to note any errors or additions you hope to make to the code in the future. These notes to yourself are called comments.

You can include comments in the code in two ways. The keyword REM at the very beginning of a line tells Liberty BASIC that the text on the line is a comment. Liberty BASIC then ignores everything on that line of code.

REM This is a comment. Liberty BASIC ignores this text!

You can also begin a line of code with an apostrophe, which looks like this. ' It works just the same as REM.
'This is a comment. Liberty BASIC ignores this text!

The apostrophe gives you an additional ability. Liberty BASIC will ignore the text following an apostrophe within a line of code, as long as the apostrophe is not contained inside of quoted text. In the following code, Liberty BASIC reads the instruction to print "Hello, World!" but it ignores the comment after the apostrophe.

Print "Hello, World!" 'My first program!

Lesson Map | Next > Mainwin Summary