by Jon Ripley, April 2007

This page is intended to contain information that is relevant to RISC OS users using BBC BASIC for Windows.

Loading BBC BASIC for Windows programs on RISC OS


RISC OS has no default method of loading or saving BBC BASIC for Windows programs so a third party conversion tool is required.

To convert BBC BASIC programs between the Acorn and Windows tokenised formats use the Basic Converter application by Jonathan Harston. Once programs are retokenised into Acorn format or converted to text they can be edited with any RISC OS text editor.

BB4W can load Acorn tokenised format programs and no special steps are required to transfer the application back to Windows. Using the Basic Converter application is optional in this case.

Tokenisation issues


When a BBC BASIC for Windows program that has been saved in Acorn format is reloaded into the BB4W editor the keywords PRIVATE and BY will not be tokenised. To ensure that the program is tokenized correctly load the program into the BB4W editor and type the following key combinations to force the editor to retokenise the program:

  1. CTRL+A - Select the entire program
  2. CTRL+X - Cut the program to the clipboard
  3. CTRL+V - Paste the program from the clipboard

Crunching programs on RISC OS


BBC BASIC for Windows has a built-in program cruncher and there is no need to crunch BB4W programs using RISC OS program crunchers. BB4W has a built-in cruncher and there are some fundamental differences between the RISC OS and Windows versions of BBC BASIC that prevent crunching on RISC OS being viable. Some major problems include:

  • No current RISC OS crunching applications are aware of the BBC BASIC for Windows tokenised format.
  • Shortening variable names breaks programs that use the keywords PRIVATE and BY.
  • Shortening variable names breaks programs that use system variables.
  • Removing spaces and concatenating lines breaks assembly language.
  • Concatenating lines breaks any code that uses the ON CLOSE|MOUSE|MOVE|SYS constructs.
  • Concatenating lines breaks any code that uses the line continuation '\' directive.

Environment differences

Serial device

On windows the serial device can be opened for input and output on the same channel, whereas on RISC OS the serial device has to be opened seperately for input and output.
  REM Open serial device on Windows
  ser%=OPENUP"COM1: 9600,8,N,1"
 
  REM Open serial device on RISC OS
  serin%=OPENIN("Serial:")
  serout%=OPENOUT("Serial:")

If you are converting code and are tempted to use:
  serin%=OPENUP"COM1: 9600,8,N,1":serout%=serin%
you must be careful not to close both serin% and serout%, as both variables point to the same channel. The following will give an error when trying to CLOSE#serout% as it is trying to close an already closed channel:
  CLOSE#serin%:CLOSE#serout%
Code similar to the following should be used, also using the code to prevent multiple cascading errors on closing (see Forcing a variable to exist):
  IF serin%=serout% THEN serout%=0
  IF serin% THEN temp%=serin%:serin%=0:CLOSE#temp%
  IF serout% THEN temp%=serout%:serout%=0:CLOSE#temp%