Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Compatibility

tiko is compatible with FreeBASIC: it implements FreeBASIC's fb dialect, and a great deal of existing FreeBASIC code compiles with it unchanged. This section is for reading and bringing over that code. It shows the older forms tiko still accepts, the ones it refuses, and what modern tiko code writes instead. Everywhere else on this site the modern forms are used.

Older code usually lives in .bas files, with .bi headers. tiko compiles a .bas file exactly as it compiles a .tiko one:

'' Older code that tiko still compiles: a .bas file, the legacy
'' string type, long and integer, while ... wend, + to join strings.
dim as string names(1 to 3)
names(1) = "ada" : names(2) = "grace" : names(3) = "alan"

dim as long i = 1
dim as integer total = 0
while i <= 3
    print ucase(left(names(i), 1)) + mid(names(i), 2)
    total = total + len(names(i))
    i = i + 1
wend
print "letters:"; total

Output

Ada
Grace
Alan
letters: 12

The same program, written the way the rest of this site writes it:

'' The same program as modern tiko writes it.
dim names( 1 to 3 ) as ustring = { "ada", "grace", "alan" }

dim as int32 total = 0
for each n in names
    print ucase( left( n, 1 ) ) & mid( n, 2 )
    total += len( n )
next
print "letters:"; total

Output

Ada
Grace
Alan
letters: 12
Older formModern tiko
.bas sources, .bi headers.tiko sources, .ti headers
stringustring, which holds text rather than bytes (next pages)
long, integerint32, int64; integer only where pointer size is the point
while … wenddo while … loop
+ to join strings&, which also converts numbers
a counter and a loopfor each, and arrays with initialisers

FreeBASIC has several dialects, chosen with #lang; tiko implements fb only. Code that asks for another is refused:

'' Older code sometimes asks for an older dialect. tiko has one.
#lang "qb"
print "hello"
dialect.bas(2,1): error TKO0317: unsupported language mode 'qb'; tiko-lang implements "fb" only
     |
   2 | #lang "qb"
     | ^

Code written for the qb or fblite dialects has to be brought across to fb. The pages that follow cover the forms that matter most: inline data, jumps and subroutines, and type suffixes and the two string types.

Activities

  1. Rewrite classic.bas with do while … loop and &, keeping the .bas extension, and check it still compiles.
  2. Rename classic.bas to classic.tiko. Does anything change?