Index


RISC World

Q BASIC to BBC BASIC

Martin Carradus introduces his BASIC converter

What is it?

!Q_BBC is designed to convert programs written in Q BASIC, into BBC BASIC, which can then be run on RISC OS computers. !Q_BBC tries to convert as many Q BASIC constructs it can, although users are advised to read the Known Restrictions section below.

Installing !Q_BBC

Note that this application will only work on writable media, not on CD ROMs! Having unzipped the compressed file containing the !Q_BBC application, drag the whole application to the directory that you wish to keep it in. Double click on the !Q_BBC icon, an icon then appears on the icon bar, then drag a Q BASIC file to the bar icon, or left click on the bar icon and drag the Q BASIC file to the 'SetUp' panel that appears.

This enters the file name into the upper slot on the panel. Alternatively the file name may be typed manually into this slot.

Select the appropriate options on the 'SetUp' panel, then click on the 'Run' icon on this panel. After a while a BBC BASIC file is offered for saving in the same directory as the Q BASIC, but with its name prefixed with "BBC".

Selecting the 'Help' or 'Description' buttons on the 'SetUp' panel and clicking on the 'Run' button gives out extra information.

Additional Help is available by clicking the middle 'Menu' button over the bar icon and clicking over the 'Help' entry on the menu that appears, or by using the Acorn !Help application in the 'Apps' directory on the icon bar.

Known Restrictions

Q BASIC will not run a FOR loop when its index initially exceeds its final value, unlike BBC BASIC, which always executes a FOR loop at least once, so there is a problem there. Also Q BASIC initialises all variables to zero. BBC BASIC does not automatically initialise variables. The BBC BASIC interpreter message 'Unknown or missing variable' means that you have not initialised a variable before the point at which its value is required to be known. An output listing of all the identifiers used in the program can be produced that attempts to detect and mark those variables that are used before their point of initialisation.

There could be numerical analysis problems to do with the accuracy of the representation of numbers. Q BASIC has integer variables of both 16 bits and 32 bits and floating point of 32 bits and 64 bits, whereas BBC BASIC always uses 32 bits for integer variables and 40 bits for floating point variables.

Many Q BASIC constructs were found to be untranslatable to BBC BASIC.

A message appears either within a special PROC or FN call in the translated file when this occurs. In the case of some errors, the resulting actual BBC BASIC line length may not agree with the line length given in the file and BBC BASIC editors will not accept it, giving out the message: 'Bad BASIC program'. However if only simple constructs are being used e.g. DO, WHILE and FOR loops, GOTO, GOSUB, ON... GOTO, ON ... GOSUB, SELECT, IF ... THEN ... ELSE ... ,EVAL, numerical calculations, logical conditions and PRINT and INPUT, then the Q BASIC should perform exactly the same in BBC BASIC.

Unfortunately the commands DRAW, PLAY, PUT and GET have not been translated. Also other graphics commands suffer from the fact that BBC BASIC graphic co-ordinates are measured from the lower left hand corner of the screen, whereas Q BASIC graphics are measured from the upper left hand corner. The author has attempted to deal with this appropriately. Also the scaling is different. IBM Screen modes were also found to be difficult to match with equivalent Acorn Screen modes. The IBM colouring system is also not the same as the Acorn scheme.

In addition, PEEK, POKE and random access files could not be mimicked in BBC BASIC.

Extra PROCs and FNs, which were needed to mimic certain constructs in both GW-BASIC and Q BASIC, are present in the supplied 'BBCLib', which is called in via an injected LIBRARY command. 'BBCLib' should be in <Obey$Dir> when the BBC BASIC is running or an error is generated. It is also present within the !Q_BBC application. One function attempts to translate from IBM file names to equivalent Acorn file names.

Currently, will not handle multi-line DEF FN statements.

!Q_BBC attempts to detect non- Q BASIC programs and complains.

Every attempt has been made to test out the translator, but the author was unable to obtain live code and just had to devise test programs, so bugs could still exist undetected.

NB !Q_BBC will only handle those Q BASIC programs with line labels, not numbers. The author has produced an application, !QLine_Out, present with !Q_BBC, which strips out line numbers from a Q BASIC program and outputs an equivalent labelled Q BASIC program. This, in turn, can be offered to !Q_BBC for translation. !QLine_Out will detect and leave unchanged those programs already with labels. !Q_BBC will complain about line numbers in the supplied Q BASIC.

Other programmers' tools are available from my website, shown at the bottom of this article, in particular (shortly) a GW-BASIC to BBC BASIC Translator.

For good measure, I have included with this !Space_Out that removes trailing spaces and tabs in lines from text files.

Licence Agreement

Users of !Q_BBC must accept this disclaimer of warranty: "!Q_BBC is supplied as is. The author disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The author assumes no liability for damages, direct or consequential, which may result from the use of !Q_BBC."

!Q_BBC is a "shareware program" and is provided at no charge to the user for evaluation. Feel free to share it with your friends, but please do not give it away altered or as part of another system. The essence of "user-supported" software is to provide personal computer users with quality software without high prices, and yet to provide incentive for programmers to continue to develop new products. If you find this program useful and find that you are using !Q_BBC and continue to use !Q_BBC after a reasonable trial period, you must make a registration donation of 5 (UK) or $8 (US) to Martin Carradus.

The 5 (UK) or $8 (US) registration donation will license one copy for use on any one computer at any one time. You must treat this software just like a book. An example is that this software may be used by any number of people and may be freely moved from one computer location to another, so long as there is no possibility of it being used at one location while it's being used at another. Just as a book cannot be read by two different persons at the same time.

Commercial users of !Q_BBC must register and pay for their copies of !Q_BBC within 30 days of first use or their license is withdrawn. Site-License arrangements may be made by contacting Martin Carradus. Anyone distributing !Q_BBC for any kind of remuneration must first contact Martin Carradus at the address below for authorization.

You are encouraged to pass a copy of !Q_BBC along to your friends for evaluation. Please encourage them to register their copy if they find that they can use it. All registered users will receive a copy of the latest version of the !Q_BBC application.

To apply for your own copy of !Q_BBC, write to:-

Martin Carradus
Leaf Mindcraft
c/o 27 Wells Road
Ilkley
West Yorkshire
LS29 9JE
U.K

N.B. Do not send cash. Please make cheques made payable to "Mr. M.K.Davies" for the amount given above. Other applications are available for free download from www.martinkd.freeuk.com and also from www.melotech.co.uk.

Martin Carradus

 Index