Comments

<< Click to Display Table of Contents >>

Navigation:  ThinBASIC Core Language >

Comments

 

Commenting the code

 

Comments are regions of text that thinBasic interpreter will ignore but may contain information that is useful to the programmer.

 
Commenting source code is a good practice for every programmer. Comments serve as a sort of in-code documentation.

For this reasons thinBasic has implemented different ways in which programmer can add comments into thinBasic scripts:

 

REMREM

 

classic Basic REM keyword

single quote '

special single quote cases

c style block comments

c++ style comment

 

 

REM keyword

 

REM keyword is the most known and classic Basic way to add comment. For example

 

REM ------------------------------------------------

REM This is the start of the main program

REM ------------------------------------------------

 

Single quotation mark (')

 

Single quotation mark (') is another classical Basic way to add remarks. Example:

 

'------------------------------------------------

' This is the start of the main program

'------------------------------------------------

 

It it a more flexible way because it allows to add remarks on a line following another statement. For example

 

DIM Msg AS STRING   '---This variable will be used ...

 

C Like remarks

 

thinBasic allows usage of C-Like comments using /* ... */ pairs. They can be used as a block or can be used on a line following another statement. Examples:

 

/*

 ------------------------------------------------

 This is the start of the main program

 ------------------------------------------------

*/

 

DIM Msg AS STRING   /* This variable will be used ... */

 

C++ Like remarks

 

thinBasic allows usage of C++ single line comment using //

Examples:

 

// This is the start of the main program

 

DIM Msg AS STRING   // This variable will be used

 

Special single quotation mark (') remarks

 

There are special single quotation mark (') remarks followed by [] that are interpreted by thinAir (thinBasic IDE) and thinDebug (thinBasic debugger) in a special way and they can be used to classify remarks in different types.

 

For example, using special single quotation mark like the following:

 

'[] <enter your annotation here>

'[!] <pay attention note: important>

'[o] <this part needs to be optimized>

'[t] <this part needs to be tested>

'[todo] <Something to do here>

'[breakpoint] <Any note here. Breakpoint will be set to line following this statement>

 

will be interpreted and identified by the thinAir in the following way permitting a very flexible way to keep your code organized:

 

 

Finally another special single line quotation mark is the following:

 

'[book] <Bookmark text>

 

It allows to add code bookmarks for quick jump using F2 or Shift+F2 keyboard shortcuts.