Code Basics

Top  Previous  Next

There are several important things you should know about writing in Tibbo Basic:

You Can Put Comments in Your Code

The apostrophe character marks the beginning of a comment. Anything following this character until the end of a line is considered to be a comment, and will not be processed by the compiler.

 

 

x = 1 + 1 ' I am a comment!

' x = y/0 <--- this line would not cause an error, because it won't even execute! It is commented.

 

 

The only exception to this is that when including an apostrophe within a string (between double quotes) it is not counted as a comment. See:

 

 

s = "That's a string!" ' Notice that the word that's contains an apostrophe.

 

 

Comments cannot span multiple lines. A line break terminates a comment. If you want to make a multi-line comment, each line of your comment must begin with an apostrophe.

Tibbo Basic Doesn't Care About Spaces!

See:

 

 

y =    x     +              5 ' is just like

 

y=x+5 ' and even this is OK:

 

y =

x

+

5

 

 

So, spaces, tabs and linefeeds carry no special meaning in Tibbo Basic. Use them or lose them, as you like. The only exceptions are the If.... Then... Else Statement and comments.

Tibbo Basic Is Not Case Sensitive!

See:

 

 

Z = X + Y ' is just like

z = x + y

r = Q + KeWL ' even something like this is legal.

DiM MooMoo As iNTeGER ' this, distatesful as it may be, is still legal. :)

 

 

Capital letters just don't matter. Really.

How to Use Double Quote Marks

Double quote marks are used for marking string literals. Simply put, a string literal is a constant string value -- like "hello world".

 

 

s = "I am a string literal!"

s1 = s

 

How to Use Single Quote Marks

These are different than the apostrophes which begin a comment. An apostrophe looks like this ' while a single quote mark looks like this ` and is usually located on the tilde (~) key. Single quote marks are used to define a numerical constant which contains the value for an ASCII code. For example:

 

 

dim b as byte

dim w as word

b = `q` ' the variable b now contains the value 113, which is the character code for q.

w = `LM` ' this is also legal, see below.

 

 

The notation used in the second example above actually places the ASCII value of L into the higher byte of a word-type variable, and the ASCII value of M into the lower byte of that variable. It may seem confusing at first, but it is also legal.

 

note_warning-wt

Note that a this isn't the same character as an apostrophe. An apostrophe is ' and a single quote-mark is a `. Usually, the single quote mark is found on the tilde (~) key, and the apostrophe is found on the double-quote (") key.

How to Define Constants In Different Bases

Tibbo Basic allows you to assign values to constants using decimal, hexadecimal or binary notation. Decimal notation is the default. To assign a hexadecimal value, you must use the prefix &h before the first hexadecimal digit of your value. To assign a binary value, you must use the prefix &b in the same manner. So:

 

 

q = 15 ' this is 15, in decimal.

q = &hF ' this is still 15, just in hex.

q = &b1111 ' and this is also 15, just in binary notation.

 

 

These prefixes hold true whenever values are used -- there are no exceptions to this rule. Whenever a numeric value is used, it may be preceded by one of these prefixes and will be interpreted correctly.

How to Use Colons

Colons are actually not necessary in most parts of Tibbo Basic. They are a traditional part of many BASIC implementations, and are often used to group several statements in one line. However, since Tibbo Basic doesn't really care about spaces anyway, they lose their relevance.

No Tibbo Basic statements require the use of colons.