Blog Post

Small Basic Blog
1 MIN READ

Small Basic Comments

Ed Price's avatar
Ed Price
Former Employee
Feb 12, 2019
First published on MSDN on Aug 06, 2014

Authored by Ed Price


This is an excerpt from this great TechNet Wiki article:

Small Basic: Programming Tips by litdev



Comments


A comment in Small Basic starts with an apostrophe ' and is highlighted in green.  Anything after it is ignored to the end of the line.

'Calculate distance between objects

distance = Math . SquareRoot ( ( x - a ) * ( x - a ) + ( y - b ) * ( y - b ) ) '(x,y) is the player




Comments are not just for others reading your code, they help remind you later why you did something.  More importantly they show the thinking behind the code and the ideas about how the program should work.

Try to add comments that explain something complex or why you did something one way or another.  They should remind you and help someone else understand the overall thinking you had when you wrote the program.

The 'more comments the better' is not good, the following comment adds nothing.

x = x + 5 'Add 5 to x




Sometimes comments can be used to visually separate sections of your code like the start of subroutines.

'===================================================

'SUBROUTINES

'===================================================






Read more great tips in this TechNet Wiki article:

Small Basic: Programming Tips by litdev






Special thanks to LitDev for helping guide our community!

- Ninja Ed

Published Feb 12, 2019
Version 1.0
No CommentsBe the first to comment