DarkBasic Pro Tutorial: Using Comments & Remarks

James Cloud
Clean and easy to understand source code is key when developing games or applications in any programming language. Sloppy and uncommented source code makes a project harder to develop and hinders the projects overall progress. Hence, developers should make ready use of comments and proper formatting in their source code to insure a smooth development process. This tutorial shows how to use remarks or comments in a DarkBasic Pro project.

Commenting and Remarks

The DarkBasic Professional IDE (Integrated development environment) gives you, the developer, the ability to exclude certain written statements from being read or parsed by the DarkBasic compiler. These excluded lines of code or just plain text are referred to as comments or remarks.

Most of the time you can understand the meaning of source code written by yourself, or even code designed and written by other developers. The simplicity of the DarkBasic Professional coding language also makes the deciphering of code much easier. However, resuming a month old, 6 month old, or even a year old project while trying to remember the meaning of all your old code and functions, without having made use of comments or remarks, would likely be a daunting task.

In DarkBasic Professional there are three ways to comment out text or lines of code. Here is summary of each:

Perhaps the most common method of constructing remarks or comments is to type the "REM" statement in front of the line you wish to exclude from the compiler.

Example code:

REM Declaration of My Function
My_Function:
PRINT "My Function!"
Return

Another, and perhaps more discreet, method of commenting or remarking a line of code would be to place the "`" symbol infront of the desired line to commented.

Example Code:

` Display a Message on Screen
PRINT "This is a Message on the Screen"

If you would like to comment out an entire section or block of code simply use the REMSTART and REMEND commands. Place REMSTART above the first line of code and REMEND under the last line.

Example code:

REMSTART
My Game
2009-10
10/10/10
REMEND

The REMSTART and REMEND commands are also useful when you want to ignore a section of code for debugging purposes or any other purpose.

Published by James Cloud

I like to program and do basically anything that has to do with technology and computers.  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.