Small Basic Comments


This is an excerpt from this great TechNet Wiki article:

Small Basic: Programming Tips by  

 

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  

 

 

Special thanks to LitDev for helping guide our community!

   - Ninja Ed

 

Comments (3)

  1. anonymouscommenter says:

    'I like comments program

    TextWindow.Writeline ("Hi, I like comments sooooooooooooooooooooooooooooooooo much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")

Skip to main content