RTB is an interpreter which means that it’s slower than traditionally compiled languages such as C/C++. However it tokenizes your program into a compact intermediate state which is much quicker to interpret at run time.

Line numbers

Traditionally BASIC uses line numbers – you enter a program one line at a time and give each line its own number. The numbers can be used as the target of GOTO and GOSUB statements.

No line numbers

Using the built-in screen editor, you can write programs that don’t use line numbers – this is more in thinking with modern programming techniques where the use of GOTO is often frownwd upon. Rather than use GOTO (and GOSUB), there are modern methods for calling named procedures and modern looping constructs too.

Data types and variables

RTB Supports two data types: Floating point (or real) numbers using IEEE 754 double precision (64-bit format), and character strings. Strings may be any length up to the limit of available RAM.

Arrays of numbers and strings are permitted and arrays can have any number of dimensions and indices – again limited by the available RAM.

Array indices can be numeric, or string based (to create a form of associative array)

Variable names can be any length up to the limit of the maximum line length allowed (currently 1024 characters).

Flow control

In addition to the traditional BASIC GOTO statement (when you use line numbers), RTB supports a single-line IF…THEN construct and a multi-line IF…THEN…ELSE…ENDIF construct, and a SWITCH…CASE…ENDSWITCH construct.


RTB supports the traditional BASIC FOR loop, but also implements a new unified looping construct using the REPEAT…CYCLE construct with WHILE or UNTIL at the top or bottom of the loop.

Procedures and Functions

In addition to the traditional GOSUB…RETURN, RTB supports named procedures and functions with provision for local variables. These can also be called recursively.


RTB supports traditional Cartesian coordinate plotting as well as turtle graphics. There is also a sprite package. The graphics are available in 2 modes – a low and high resolution mode. There are 16 built-in named colours, but a full 24-bit colour pallet is supported.


On the Raspberry Pi, RTB provides access to the on-board GPIO pins using the standard wiringPi pinMode, digitalRead and digitalWrite statements. It also supports GPIO extensions via Arduino and various expansion chips such as shift-registers, I2C and SPI GPIO expansion chips.

Other features

Random and sequential access file handling is supported, as well as serial port access.


Overview — 13 Comments

  1. Hi.

    Is there a way to start programs out of the basic code? I’d like to start a commandline tool (raspistill) when a signal reaches an gpio-port. But I fail at starting a program…

    BTW: is there any further documentation of your BASIC Interpreter?

  2. BTW: The error message when I try using SHELL or EXEC is “Undimensioned array”

    But it’s pretty likely I’m doing some syntax errors; I’m a Beginner. I try starting the program by using:
    …I’ve also tried different variations.

    • There are no SHELL or EXEC commands in RTB. Right now there is no way inside an RTB program to run an external one.

      If you need to start something before you run a BASIC program, then you’ll need to wrap it in a little shell script – start the first program, then run RTB.

      The only manual right now is the reference manual, there is no tutotial manual – yet. However looks like I’ve not added the link to the manual in the site which I thought I had, so: http://project-downloads.drogon.net/rtb/rtb.pdf


      • Ok, thanks for the reply… looks like I have to learn another programming language then. (I want to start the program event triggered so a wrapper won’t help I guess)

        • I’m not 100% sure exactly what you’re trying to achieve though – want to break it down a bit so I can make some more suggestions?


  3. I am new to the raspberry pi so I am in learning mode. I have done a boat load of bread boarding/ programming in the old 8 bit world. I want to do some project that use the GPIO lines. I am learning python but am on old TurboBasic/PowerBasic guy. I started with bwbasic and controlling the IO lines was a bit messy but worked but I saw with RTB that is was very clean and alot like using in/out peek/poke. had no issue loading it and runs ok but I ran into a funny quirk. When I write to the IO pin its off. When I write to pin 4 pin 23 actually goes high/low. When I write to pin 5 ,, 24 toggles. Is this a known issue and I can fix it ?

    I start both below with sudu

    Ex. BWBASIC (works and actually toggeles pin 4)
    echo “4” > /sys/class/gpio/export
    10 OPEN ”O”,#1, “/sys/devices/virtual/gpio/gpio4/direction”,2
    20 PRINT #1,”out”
    30 CLOSE #1
    40 OPEN ”O”,#4, “/sys/devices/virtual/gpio/gpio4/value”,1
    50 PRINT #4,”1”
    60 CLOSE #4
    10 PinMode (4,1)
    20 DigitalWrite (4,1)
    30 END

    with this pin 23 toggles. What am I doing wrong ?


    • It’s a mis-understanding in the way the pin numbering works. RTB uses the wiringPi pin numbering scheme and that other BASIC and your code is using the BCM_GPIO numbers.

      Do study the chart on: http://wiringpi.com/pins/

      wiringPi pin 4 is BCM_GPIO pin 23 – so if you use 23 in the first bit of code then it should work on the same pin.

      (or use pin 7 in the RTB program as BCM_GPIO 7 is wiringPi pin 4)


      • Thanks!! Like I said I am new to this platform and RTB. Guess RTB can also stand for Read The Book 🙂 I appreciate your time replying

  4. GPIO and Serial programming is very straight forward in RTB, awesome job! has any one had success with I2C and RTB ? Any examples ?

  5. Hi Gordon,

    I haven’t heard from you and wanted to make sure you’re are doing okay. I would love to get RTB wrapped up on Android and out there on Google Play.