Constants and Variable Initialization

Constants in Tibbo BASIC

Numerical constants can be in decimal, binary (&b), or hex (&h) notation.

ASCII codes can be used in constants as well. To achieve this, enclose a character in ``. For 16 and 32-bit variables, you can enclose up to two or four characters between ``.

String constants can include escape sequences (\x00) to define unprintable characters. This functionality is borrowed from C. There are also several predefined escape sequences.

BASIC has a dedicated const statement to define names for constants. The #define preprocessor directive can also be used.

It is possible to use expressions in constants.

No mechanism is provided to "gang-initialize" array members.

Tibbo BASIC
dim x as char=-100/5 'decimal notation + expression
dim i as word=&b1010111100000101 'binary notation
dim dw as dword=&hFFFFFFFF 'hex notation
dw=`0123` 'The result will be &h30313233
dim s as string="This is a test\x0A\x0D" 'string constant with LF/CR
Const TIMEOUT_PERIOD=5 'using the const statement
Const DOUBLE_PERIOD=TIMEOUT_PERIOD*2 'expression using another constant
Const DEVICE_NAME="Monitor 1"
x=TIMEOUT_PERIOD
s=DEVICE_NAME
#define TIME_GAP 10
dim arr(5) as word
arr(0)=10 'array members must be initialized one-by-one
arr(1)=25

Constants in Tibbo C

Numerical constants can be in decimal, hex (0x5A3F), octal (0123), or binary (1101b) notation. The latter is an import from Tibbo BASIC.

As per ANSI C, ASCII codes can be expressed with ' '. For 16 and 32-bit variables, you can enclose up to two or four characters between ' '.

As per ANSI C, string constants can include escape sequences (\x00) to define unprintable characters. There are also several predefined escape sequences.

There is no const or similar statement (and this is strongly criticized in ANSI C). Use the #define preprocessor directive instead.

It is possible to use expressions for constants.

All members of an array can be initialized at once using the ={,,,}; or ="    " syntax.

In Tibbo C, it's NOT POSSIBLE to do this: char *b="123" (because constant strings of Tibbo devices are stored in flash memory).  

Tibbo C
char x=-100/5; //decimal notation + expression
unsigned char uc=11001010b; //binary notation
signed int si=0345; //octal notation
unsigned int ui=0x5A3F; //hex notation
unsigned long ul='0123'; //The result will be 0x30313233
string s="This is a test\x0A\x0D"; //string constant with LF/CR
#define TIME_GAP 10
x=TIME_GAP*2;
unsigned char arr[]={1,10,5,3}; //init an array
unsigned int arr2[2][2]={{1,2},{3,4}}; //init a two-dimensional array
char arr3[]="Test"; //NULL-character will be added

Predefined Escape Sequences (Tibbo BASIC and C)


Constants and Variable Initialization

Constants in Tibbo BASIC

Constants in Tibbo C

Predefined Escape Sequences (Tibbo BASIC and C)