Beginner's Programming Tutorial in QBasic

(Kiana) #1

Adding documentation to your programs


Documenting your program (also called "commenting") allows you to remind yourself about
something in your program. Plus, if your program is seen by other people, documenting can helpthem understand your code.


The REM (remark) command enables you to add comments to your program without the text
being treated like an instruction.
CLSPRINT "Some text"
REM This text is ignored.
REM This program clears the output screen,
REM and then prints "Some text."


TIP: You can use an apostrophe instead of the
REM command.
' Comment goes here

You can add REM to the same line as another command by placing a colon after the first
instruction.
CLS: REM This command clears the screenPRINT "Text": REM This command prints "Text" to the screen
PRINT 534: REM This prints the number 534 to the screen


NOTE: If you use an apostrophe instead of REM while doing this, you do not need to add a colon.
CLS ' This command clears the screenPRINT "Text" ' This command prints "Text" to the screen
PRINT 534 ' This prints the number 534 to the screen

Free download pdf