<!-- Generated by Harlequin WebMaker 2.2.3 (23-Apr-1996)
LispWorks 3.2.2 -->
<HTML> <HEAD>
<TITLE>Appendix&nbsp;D</B>:  BBC BASIC</TITLE>
</HEAD>
<BODY bgcolor="#ffffff">
<A NAME=HEADING9> </A>
<A HREF="BOOK3_14.H"><IMG ALIGN=BOTTOM SRC="next" WIDTH=69 HEIGHT=24></A> <A HREF="BOOK3_6.HT"><IMG ALIGN=BOTTOM SRC="prev" WIDTH=69 HEIGHT=24></A> <A HREF="../BOOKB/USERGUIDE"><IMG ALIGN=BOTTOM SRC="top" WIDTH=69 HEIGHT=24></A> <A HREF="../BOOKB/TOC.HTM"><IMG ALIGN=BOTTOM SRC="content" WIDTH=69 HEIGHT=24></A> <A HREF="../INDEX/MAIN.HTM"><IMG ALIGN=BOTTOM SRC="index" WIDTH=69 HEIGHT=24></A><P>
RISC OS 3.7 User Guide<P>
<HR>
<A NAME=HEADING9-0> </A>
<H1>Appendix D</B>:  <A NAME=MARKER-9-1> </A><A NAME=MARKER-2-2> </A>BBC BASIC</H1>
<HR>
BBC <A NAME=MARKER-2-3> </A>BASIC is still one of the most popular and widely-used programming languages. It consists of special keywords from which the programmer can create sequences of instructions, or programs, to be carried out by the computer. Such programs might perform calculations, create graphics on the screen, manipulate data, or carry out virtually any action involving the computer and the devices connected to it.<P>
The BASIC language operates within an environment provided by the computer's operating system. The operating system is responsible for controlling the devices available to the computer, such as the keyboard, the screen, and the filing system. For example, it is the operating system which reads each key you press and displays the appropriate character on the screen. Operating system commands can be entered directly from within BASIC by prefixing them with an asterisk (*).<P>
If you want to find out more about the <A NAME=MARKER-2-4> </A>BBC BASIC programming language, you need the <Cross Ref>BBC BASIC Reference Manual<I></I> available from your Acorn supplier.<P>
On-line help is available within BASIC; just type HELP (in uppercase) for more information.<P>
<A NAME=HEADING9-5> </A>
<H2> BBC BASIC V and VI</H2>
There are two variants of BBC BASIC supplied with RISC OS 3</B>: BASIC V and BASIC VI.<P>
BASIC V is in the ROM and is almost identical to the BASIC V supplied with earlier versions of RISC OS. A small number of faults have been corrected. <P>
BASIC VI is essentially the same as BASIC V, but it uses 8 bytes (or 64 bits) to store floating point numbers. BASIC V only uses 5 bytes, so it is slightly less accurate. The 8 byte representation used follows the <A NAME=MARKER-2-5> </A>IEEE standard. Unlike BASIC V, BASIC VI makes use of a hardware <A NAME=MARKER-2-6> </A>floating point unit if it is fitted.<P>
<P>
<A NAME=HEADING11-2> </A>
<H2> Entering BASIC</H2>
<A NAME=HEADING11-3> </A>
<H3> Basic V</H3>
To start BASIC V, display the Task manager menu (click Menu over the Acorn icon at the bottom righthand corner of the desktop). Choose the <B>Task window</B> option and then type the following</B>: <P>
<CODE>BASIC</CODE><P>
Press Return, and the BASIC V version and memory will be displayed on the screen. <P>
BASIC can also be started from the New Task option on the Task Manager or from the command line (press F12). <P>
<A NAME=HEADING11-8> </A>
<H3> Basic VI</H3>
BBC BASIC VI is different to BBC BASIC V in that it is stored on disc, not in the computer's ROM. BASIC VI is also known as BASIC64.<P>
BASIC VI is used by some applications (for example SciCalc) so it may get loaded into memory without you having to take any special action. <P>
To start BASIC VI, display the <A NAME=MARKER-2-7> </A>Task manager menu (click Menu over the Acorn icon at the bottom righthand corner of the desktop). Choose the <B>Task window</B> option and then type the following</B>: <P>
<CODE>System</B>:Modules.BASIC64</CODE><P>
Press Return, and the BASIC VI version and memory option will be displayed on the screen. (<B>Note</B></B>: You can't just type BASIC64, as the BASIC64 module is not in the library directory).<P>
<A NAME=MARKER-2-8> </A>BASIC 64 can also be started from the New task option on the Task manager menu or from the command line (press F12). <P>
BASIC files saved from both BASIC V and BASIC VI are the same and can be run using either BASIC.<P>
<A NAME=HEADING11-16> </A>
<H2> Leaving BASIC</H2>
To leave BASIC, type <CODE><A NAME=MARKER-2-9> </A>QUIT</CODE> (which must be in uppercase) or type <CODE>*Quit</CODE>.<P>
<A NAME=HEADING11-18> </A>
<H2> Features in BASIC VI</H2>
The CRUNCH command strips various spaces from a program. Its argument is a 5-bit binary word. Each bit in the word has a different meaning (for instance bit 0 controls the stripping of spaces before statements; bit 2 controls the stripping out of REM statements).<P>
The TEXTLOAD command can load a file that is either a BASIC program, or a BASIC program that was saved as a text file. In the latter case, TEXTLOAD automatically renumbers the program. TEXTSAVE stores a BASIC program as a text file, and strips out the line numbers.<P>
<A NAME=HEADING11-21> </A>
<H2> Writing and editing BASIC files</H2>
Edit will automatically convert BASIC files to and from BASIC tokenised format. Now all editing of BASIC files can be done using <A HREF="../BOOK2B/D_6.HTM"> Edit</A>.<P>
<A NAME=HEADING11-23> </A>
<H2> Command line syntax for BASIC</H2>
The following pages describe in full the command line interface for BASIC V and BASIC VI.<P>
<HR>
<A NAME=HEADING12-0> </A>
<H1> *BASIC</H1>
<HR>
The command to enter the BASIC V interpreter.<P>
<A NAME=HEADING12-2> </A>
<H3> Syntax</H3>
<CODE>*BASIC [options]</CODE><P>
<A NAME=HEADING12-4> </A>
<H3> Purpose</H3>
To enter BASIC V.<P>
The options control how the interpreter will behave when it starts, and when any program that it executes terminates. If no option is given, BASIC simply starts with a message of the form</B>:<P>
ARM BBC BASIC V version 1.05 (C) Acorn 1989<P>
Starting with 643324 bytes free<P>
The number of bytes free in the above message will depend on the amount of memory in your Next slot. The first line is also used for the default REPORT message, before any errors occur.<P>
One of three options may follow the *BASIC command to cause a program to be loaded, and, optionally, executed automatically. Alternatively, you can use a program that is already loaded into memory by passing its address to the interpreter. Each of these possibilities is described in turn below.<P>
In all cases where a program is specified, this may be a tokenised BASIC program, as created by a SAVE command, or a textual program, which will be tokenised (and possibly renumbered) automatically.<P>
*BASIC -help<P>
This command causes BASIC to print some help information describing the options documented here. Then BASIC starts as usual.<P>
*BASIC [-chain] filename<P>
If you give a filename after the *BASIC command, optionally preceded by the keyword -chain, then the named file is loaded and executed. When the program stops, BASIC enters immediate mode, as usual.<P>
*BASIC -quit filename<P>
This behaves in a similar way to the previous option. However, when the program terminates, BASIC quits automatically, returning to the environment from which the interpreter was originally called. If you have a variable <CODE>BASIC$Crunch</CODE> defined, it also performs a CRUNCH %1111 on the program. This is the default action used by BASIC programs that are executed as * commands. In addition, the function QUIT returns TRUE if BASIC is called in this fashion.<P>
*BASIC -load filename<P>
This option causes the file to be loaded automatically, but not executed. BASIC remains in immediate mode, from where the program can be edited or executed as required.<P>
*BASIC @start,end<P>
This acts in a similar way to the -load form of the command. However, the program that is 'loaded' automatically is not in a file, but already in memory. Following the @ are two addresses. These give, in hexadecimal, the address of the start of the in-core program, and the address of the byte after the last one. The program is copied to PAGE and tokenised if necessary. <P>
Note that the in-core address description is fixed format. It should be in the form</B>:<P>
@xxxxxxxx,xxxxxxxx<P>
where x means a hexadecimal digit. Leading zeros must be supplied. The command line terminator character must come immediately after the last digit. No spaces are allowed.<P>
*BASIC -chain @start,end<P>
This behaves like the previous option, but the program is executed as well. When the program terminates, BASIC enters immediate mode.<P>
<CODE>*BASIC -quit @start,end</CODE><P>
This option behaves as the previous one, but when the BASIC program terminates, BASIC automatically quits. The QUIT flag will return TRUE during the execution of the program.<P>
<A NAME=HEADING12-29> </A>
<H3> Examples</H3>
*BASIC <P>*BASIC -quit shellProg <P>*BASIC @000ADF0C,000AE345 <P>*BASIC -chain fred<P>
<P>
<DD>
</DL>
<HR>
<H1> <A NAME=MARKER-2-11> </A>*BASIC64</H1>
<HR>
The command to enter the BASIC VI interpreter.<P>
<A NAME=HEADING13-2> </A>
<H3> Syntax</H3>
 <A NAME=MARKER-2-12> </A>*BASIC64 [options]<P>
This assumes that the BASIC64 module has been 'seen'. If not, you need to type<P>
*System</B>:Modules.BASIC64<P>
<A NAME=HEADING13-6> </A>
<H3> Purpose</H3>
This has exactly the same purpose as the *BASIC command, and takes the same options, the only difference being that it enters the BASIC VI interpreter instead of the BASIC V interpreter. Additionally CRUNCH is used automatically by BASIC64.<P>
If no option is given, BASIC VI simply starts with a message of the form</B>:<P>
ARM BBC BASIC VI version 1.05 (C) Acorn 1989  Starting with 581628 bytes free.<P>
The number of bytes free in the above message will depend on the amount of free space in your Next slot.<P>
<A NAME=HEADING13-11> </A>
<H3> Examples</H3>
*BASIC64 <P>*BASIC64 -quit shellProg <P>*BASIC64 @000ADF0C,000AE345 <P>*BASIC64 -chain fred<P>
<A NAME=HEADING13-15> </A>
<H2> Features available in RISC OS 3 Version 3.50 or later</H2>
The version of BASIC in your computer has been <A NAME=MARKER-2-13> </A>extended for use with the new systems available.<P>
<A NAME=HEADING13-17> </A>
<H3> Colour</H3>
<UL>

<LI>COLOUR n [TINT t]</B>: set text foreground colour [and tint]<P>

<LI>GCOL n [TINT t]</B>: set graphics foreground colour [and tint]<P>
</UL>
If n is less than 128, the foreground colour is set to colour n<P>
If n is greater than 128, the background colour is set to colour n-128<P>
<UL>

<LI>COLOUR n,p</B>: set palette entry for logical colour n to physical colour p.<P>

<LI>COLOUR r,g,b</B>: set colour to r, g, b.<P>

<LI>COLOUR n,r,g,b</B>: set palette entry for n to r, g, b physical colour.<P>

<LI>GCOL &lt;action&gt;,n [TINT t]</B>: set graphics foreground/background colour and action.<P>

<LI>GCOL [&lt;action&gt;,]r,g,b</B>: set colour to r, g, b.<P>
</UL>
<A NAME=HEADING13-27> </A>
<H3> Mode</H3>
Set the screen mode</B>:<P>
<UL>

<LI>MODE &lt;number&gt;|&lt;string&gt;<P>
</UL>
See <A HREF="../BOOKB/BOOK_3.HTM#HEADING3-54"><I>Changing the desktop size without changing the resolution</I> on page 16</A> for more information about this string.<P>
As a function MODE gives the current screen mode.<P>
MODE has been extended to take a pointer to a mode selector or a mode string. A mode selector is passed to OS_ScreenMode, whereas a mode string is passed to *WimpMode. The result is that if a program changes screen mode using a mode string, e.g. MODE "X800 Y600 C256 EX1 EY1", then when the program finishes that will be your desktop mode.<P>
It should also be noted that the C/G option in the mode string is implemented by *WimpMode. Hence, MODE MODE will select a default palette mode for the given current mode depth. This means that if a grey mode is selected by MODE "X800 Y600 G256 EX1 EX1" then MODE MODE will revert back to the coloured palette.<P>
<A NAME=HEADING13-34> </A>
<H3> Point</H3>
POINT (X,Y) supports 16bpp and 32bpp colours.<P>
<A NAME=HEADING13-36> </A>
<!-- TOC --><DL>
<DD>
</DL>

<HR>
<ADDRESS>RISC OS 3.7 User Guide - 20 JAN 1997</ADDRESS>
<A HREF="BOOK3_14.H"><IMG ALIGN=BOTTOM SRC="next" WIDTH=69 HEIGHT=24></A> <A HREF="BOOK3_6.HT"><IMG ALIGN=BOTTOM SRC="prev" WIDTH=69 HEIGHT=24></A> <A HREF="../BOOKB/USERGUIDE"><IMG ALIGN=BOTTOM SRC="top" WIDTH=69 HEIGHT=24></A> <A HREF="../BOOKB/TOC.HTM"><IMG ALIGN=BOTTOM SRC="content" WIDTH=69 HEIGHT=24></A> <A HREF="../INDEX/MAIN.HTM"><IMG ALIGN=BOTTOM SRC="index" WIDTH=69 HEIGHT=24></A><P>
</BODY>
</HTML> 