RTR logo

BBC BASIC for Windows

Command and Editing Window



Introduction to the IDE

When you start BBC BASIC for Windows you are presented with the command and editing window. This has the normal features which make up the modern Windows™ interface: a title bar, a set of drop-down menus, a toolbar, an editing pane and a status bar. It is possible to hide the toolbar and/or the status bar by means of selections in the Options menu.

You can move this window wherever you like on your Windows™ desktop, and you can re-size it by dragging one of the corners or sides. The bottom right-hand corner has a special area which makes it easier to resize the window by dragging there. BBC BASIC for Windows will remember the size of the window and set it to the same size when it is next started.


The title bar

Title bar
The title bar contains the name of the application (BBC BASIC for Windows), the name of the current BASIC program (or 'untitled' if the New command has been issued), a minimise button, a maximise button and a close button. If you right-click in the title bar you will get a context menu containing the Restore, Move, Size, Minimize, Maximize and Close items.

If you close the window (by clicking on the close button, selecting Close from the right-click menu or using the keyboard shortcut Alt-F4) you will be prompted to save the current program if any changes have been made.


The menu bar

Menu bar
The menu bar contains the drop-down menus File, Edit, Utilities, Options, Run and Help. These menus may be activated by clicking on the appropriate menu name or by using a keyboard shortcut (hold down Alt and press the key corresponding to the underlined character). If any of the menu items are unavailable, they will be 'greyed out' and clicking on them will have no effect.


The toolbar

Toolbar
The toolbar provides easy access to the most common commands, without having to select them from the drop-down menus, simply by clicking on the appropriate button. If any of the commands are unavailable the button will be 'greyed out' and clicking on it will have no effect. The commands for which buttons are provided are as follows:

From the File menu: New, Load, Save and Print.
From the Edit menu: Undo, Redo, Cut, Copy, Paste, Find and Replace.
From the Utilities menu: Renumber and Compile.
From the Run menu: Run, Stop, Pause, Step and Immediate.

The final (question mark) button does not correspond to any of the menu commands, but instead activates context sensitive help. If you click on this button, then click on a keyword within the editing pane, a short description of the use and function of that keyword will be displayed.


The status bar

Status bar
When a menu item is highlighted, the status bar displays a brief description of the function of that command. Otherwise, the status bar is split into seven regions: a message region (which always reads "Press F1 for Help"), the current length of the BASIC program, the current position of the text cursor (caret) in the editing pane, the current Insert/Overtype status, the current Caps Lock status, the current Num Lock status and the current Scroll Lock status.

Program length

(BBC BASIC for Windows version 3.00a or later only)
The length, in bytes, of the currently-loaded BBC BASIC program. This corresponds to the size of the file if the program is saved in tokenised (.BBC) format, and (usually) to the value of TOPPAGE when the program is running.

Cursor position

The current text cursor (caret) position is displayed in the form x,y where x is the horizontal position (the leftmost column is 0) and y is the vertical position (the topmost line is 0).

Insert/Overtype

Pressing the Insert key on the keyboard toggles between insert mode and overtype mode. Overtype mode is indicated by OVR being displayed in the status line; in this mode any character typed will over-write the existing character in that position on the line. The normal editing mode is insert mode, in which any characters typed 'push' the rest of the line to the right to make room.

Caps Lock

Pressing the Caps Lock key on the keyboard toggles the caps lock mode on and off. Caps lock mode is indicated by CAPS being displayed in the status line; in this mode the alphabetic keys (A-Z) generate capital letters, unless the Shift key is held down in which case they generate lower-case letters. When caps lock mode if off, the alphabetic keys generate lower-case letters, unless the Shift key is held down.

Num Lock

Pressing the Num Lock key on the keyboard toggles the num lock mode on and off. Num lock mode is indicated by NUM being displayed in the status line; in this mode the number keys (0-9) in the separate numeric cluster generate numbers, unless the Shift key is held down in which case they generate cursor-movement codes. When num lock mode if off, the numeric cluster generates cursor-movement codes.

Scroll Lock

Pressing the Scroll Lock key on the keyboard toggles the scroll lock mode on and off. Scroll lock mode is indicated by SCRL being displayed in the status line; BBC BASIC for Windows ignores this mode.


File menu

File menu New Load Save Save As Chain Insert Page Setup Print Recent Files Exit

The file menu is concerned with loading, saving and printing BBC BASIC programs, and with exiting from BBC BASIC for Windows. The file menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-F.

New  

The New command (keyboard shortcut Ctrl+N) deletes the current BASIC program from memory, giving you a 'clean sheet' into which to type a new program. If the previous program was not saved, you are first prompted to save it. If a BASIC program is currently running (i.e. its output window is open) the New command is inhibited.

Load  

The Load command (keyboard shortcut Ctrl+L or Ctrl+O) loads a BBC BASIC program into memory. It will accept files in BBC BASIC (86) internal (tokenised) format, in Acorn (BBC Micro or Archimedes) internal format, or in ASCII (plain text) format. The command calls up the Load dialogue box:

Load dialogue

If the previous program was not saved, you are first prompted to save it. If a BASIC program is currently running (i.e. its output window is open) the Load command is inhibited.

Save  

The Save command (keyboard shortcut Ctrl+S) saves the BBC BASIC program currently in memory to a file. The filename used is the same as that from which the program was loaded (i.e. the contents of the file are replaced). If the program was loaded from a BBC BASIC (86) or Acorn internal format (tokenised) file it will be saved as a BBC BASIC (86) internal format file (in the latter case you are warned that the file format is being altered). If the program was loaded from an ASCII (plain text) file it will be saved as an ASCII file. You can use the Save As command to override these defaults (a program must be saved in internal format if it is to be loaded at run-time with the CALL, CHAIN or INSTALL statement).

If the program was not loaded from a file (i.e. it was typed in or imported via the clipboard) the Save command will display the Save As dialogue box so you can enter the desired filename and format. If the current BASIC program is unchanged, so it doesn't need to be saved, the Save command is inhibited.

(BBC BASIC for Windows version 3.00a or later only)
If the file you are about to overwrite has been modified by another application (e.g. another copy of BBC BASIC for Windows) since it was first loaded, the Save command issues a warning. If you continue with the Save operation the modifications carried out by the other program will be lost.

Save As

The Save As command (keyboard shortcut Shift+Ctrl+S) saves the BBC BASIC program currently in memory to a file. You are prompted to select a file name and a file format: BBC BASIC internal (tokenised) format or ASCII (plain text) format. Use Save As rather than Save if you need to change the disk, directory (folder), filename or format to something different from their current values.

Chain

The Chain command loads a BBC BASIC program into memory and then runs it automatically. It is equivalent to Load followed by Run. If the previous program was not saved, you are first prompted to save it. If a BASIC program is currently running (i.e. its output window is open) the Chain command is inhibited.

Insert

The Insert command (keyboard shortcut Ctrl+I) loads a BBC BASIC program (or part of a program) into memory, but instead of it replacing the current program it is inserted in the program before the line containing the cursor (caret). This line, and subsequent lines, are 'moved down' to make space for the inserted lines.

The effect is similar to the Paste command, except that the inserted lines are read from a file (and may be in any of the formats accepted by the Load command). If a BASIC program is currently running (i.e. its output window is open) the Insert command is inhibited.

Page Setup

The Page Setup command allows you to select the page orientation (portrait or landscape) and set the size of the page margins. These affect the page layout when you print out the current BASIC program using the Print command.

Print  

The Print command (keyboard shortcut Ctrl+P) allows you to print out one or more copies of the BASIC program currently in memory. A 'dialogue box' is displayed which allows you to: Syntax highlighting
If you have a colour printer you can choose to highlight the printout in the same colours as are used on the screen (set with the Set Colours command). Alternatively you can choose to highlight the printout using underlining, italics and bold-face emphasis; these work with either a black-and-white or a colour printer.

(BBC BASIC for Windows version 5.60a or later only)
You can force a 'new page' by including the following statement in your program:

REM!Eject
When the statement is encountered printing will continue at the top of the next page.

Recent files

The nine most-recently loaded files are listed in the File menu, and can be re-loaded simply by clicking on the appropriate entry or by using the keyboard shortcuts Ctrl+1 to Ctrl+9 (or Alt-F followed by the digit 1 to 9). When one of the entries is highlighted, the full pathname of the file is displayed in the Status Bar. If the previous program was not saved, you are first prompted to save it. If a BASIC program is currently running (i.e. its output window is open) the recent files are inhibited.

Exit

The Exit command quits from BBC BASIC for Windows and closes all its windows. If the current program in memory has not been saved, you are first prompted to save it.


Edit menu

Edit menu Undo Redo Cut Copy Paste Delete Select All Find Find Next Replace

The edit menu is concerned with editing or searching the current BBC BASIC program (i.e. the program loaded into memory). The edit menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-E.

Undo  

The Undo command (keyboard shortcut Ctrl+Z) reverses the effect of the last editing operation (typing, delete, paste, renumber, insert file, replace or drop); the type of operation is indicated in the menu. If there is nothing to be undone, the message "Can't undo" is shown in grey. The maximum number of undo levels is determined by the Customize command.

Redo  

The Redo command (keyboard shortcut Ctrl+Y) reverses the effect of a previous undo command; the type of operation to be re-done is indicated in the menu. If there is nothing that can be re-done, the message "Can't redo" is shown in grey.

Cut  

The Cut command (keyboard shortcut Ctrl+X) transfers any selected text to the clipboard, and deletes it from the program. If no text is selected, the Cut command is inhibited. Once the selected text is in the clipboard, you can Paste it either elsewhere in your BASIC program or into any other application which supports pasting of text from the clipboard. Any previous contents of the clipboard are discarded.

Selected text is highlighted in reverse-video. You can select text in the following ways:

Once a block of text has been selected, you can alter the selection by holding down Shift and moving the cursor. If you want to change the start point of a selection, make the initial selection from right to left or from bottom to top. If you want to change the end point of a selection, make the initial selection from left to right or from top to bottom.

Copy  

The Copy command (keyboard shortcut Ctrl+C) transfers any selected text to the clipboard, but unlike Cut it leaves the text in the BASIC program. If no text is selected, the Copy command is inhibited. Once the selected text is in the clipboard, you can Paste it either elsewhere in your BASIC program or into any other application which supports pasting of text from the clipboard. Any previous contents of the clipboard are discarded.

See Cut for details of how text may be selected.

Paste  

The Paste command (keyboard shortcut Ctrl+V) inserts the contents of the clipboard into the BBC BASIC program at the current position of the text cursor (caret). If the clipboard contains no text, the Paste command is inhibited. You can use Paste to transfer a block of code from elsewhere in your BASIC program, or to insert a block of code which has been placed in the clipboard by any other application. For example you can transfer code examples in the BASIC documentation files into your program by first copying them to the clipboard from the Help window then pasting them at the required place.

Delete

The Delete command deletes any selected text, without copying it into the clipboard. See Cut for details of how text may be selected. The delete command has an identical effect to pressing the Delete key on the keyboard. Text which is deleted can only be recovered by using the Undo command.

Select All

The Select All command (keyboard shortcut Ctrl+A) selects the entire BASIC program. It is useful if you want to transfer the program into another application (e.g. a word processor) via the clipboard

Find  

The Find command (keyboard shortcut Ctrl+F) allows you to search your BASIC program for the occurrence of some specified text. The command opens the Find dialogue box into which you can type the text you wish to search for. You can also specify whether the case (capitals or lower-case) is significant and whether to match only an entire word (i.e. the text must be preceded and followed by non-alphabetic characters):

Find dialogue

To start the search click on Find Next, press the Return (Enter) key or use the shortcut Alt+F. The search begins at the position of the text cursor (caret) when the Find command was issued. If you want to search the entire program, ensure that you move the cursor to the start of the program before issuing the command.

If the specified text is found it is highlighted (i.e. selected) and the cursor is moved to the end of the highlighted region. The display is automatically scrolled so that the selected text is visible. Clicking on Find Next again causes the search to resume from this point and the next occurrence of the text (if any) to be found. If the text is not found before the end of the program the message "Text not found" is displayed; clicking Find Next again causes the search to restart from the beginning of the program.

You can click on Cancel at any time to abort the search and dismiss the dialogue box.

Find Next

Once the Find dialogue box has been dismissed, you can continue to search for the next and subsequent occurrences of the search string by using the Find Next command or by pressing F3. If the text is not found before the end of the program the message "Text not found" is displayed; selecting Find Next again causes the search to restart from the beginning of the program.

Replace  

The Replace command (keyboard shortcut Ctrl+R) allows you to search your BASIC program for the occurrence of some specified text and then, optionally, replace it with some different text. The command opens the Replace dialogue box into which you can type the text you wish to search for and the text you want it to be replaced with. You can also specify whether the case (capitals or lower-case) is significant and whether to match only an entire word (i.e. the text must be preceded and followed by non-alphabetic characters):

Replace dialogue

To start the search click on Find Next, press the Return (Enter) key or use the shortcut Alt-F. The search begins at the position of the text cursor (caret) when the Replace command was issued. If you want to search the entire program, ensure that you move the cursor to the start of the program before issuing the command.

If the specified text is found it is highlighted (i.e. selected) and the cursor is moved to the end of the highlighted region. The display is automatically scrolled so that the selected text is visible. To confirm that you want the text to be replaced click on Replace; this will replace the text and search for the next occurrence of the text (if any).

Alternatively if you do not wish to replace this occurrence of the text click on Find Next. This will skip the replace operation and search for the next occurrence of the text (if any). If the text is not found before the end of the program the message "Text not found" is displayed.

If you are certain that you want every occurrence of the text (from the current point to the end of the program) to be replaced, click on Replace All. You can click on Cancel at any time to abort the search and dismiss the dialogue box.


Utilities menu

Utilities menu Trace List Variables Renumber Compile

The utilities menu contains commands to aid debugging of your BASIC program, to renumber your program and to convert your program to a stand-alone executable file. The utilities menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-U.

Trace

The Trace command allows you to monitor execution of your program. Selecting this command alternately enables and disables Trace mode, as indicated by the presence of a tick mark next to Trace in the menu. You can enable (or disable) Trace mode either before executing your program or once it is running.

In Trace mode, the program statement which is currently being executed is highlighted, and this highlight moves as your program is running (unless the statement currently being executed is in a CALLed or INSTALLed module). If your program gets stuck in an 'infinite loop', you will be able to see what part of the program is being executed. If your program stops running because of an error (or an END or STOP statement) the last statement executed will remain highlighted for as long as the program's output window remains open, or until you enter a command in immediate mode.

Trace can be used in conjunction with the Pause and Step commands in order to trace execution of your program one statement at a time.

List Variables

The List Variables command opens a window which displays the current values of the variables in your program (variables which have not yet been accessed are not displayed, except for the static variables which are always listed). The displayed values change as your program runs. You can change the size of and/or scroll the List Variables window so that the variable(s) in which you are interested are displayed.

In the case of arrays, the name, number of dimensions and sizes of each dimension are displayed, but the values of the individual elements are not. If you need to monitor the value of an array element, add an appropriate statement or statements to your program to copy the value to a conventional variable.

In *FLOAT64 mode floating-point variable names (also procedure and function names) are shown with a # (hash) suffix.

You can select the List Variables command either before executing your program or once it is running. List Variables can be used in conjunction with the Pause and Step commands in order to monitor the values of variables as your program is executed one statement at a time.

Renumber  

The Renumber command allows you to renumber the lines of your program, or alternatively to remove all the line numbers (except those needed as the destination of a GOTO, GOSUB or RESTORE statement). The command opens the Renumber dialogue box into which you can type the line number for the first line of your program and the increment (step) between consecutive line numbers. Both values default to 10:

Renumber dialogue

Renumbering your program can be useful when debugging, because if an (untrapped) error occurs the line number at which the error occurred is displayed. Once your program is complete and debugged, you may prefer to remove the line numbers so as not to clutter the program listing.

The Renumber command will fail if the specified increment is zero or if the specified values would result in a line number greater than the maximum allowed (65535).

Compile  

The Compile command allows you to create a stand-alone executable file from your BBC BASIC program. Although this is not a true compiler in the traditional sense (your program is still interpreted) the end result is effectively the same. The executable file generated by the Compile command requires only Windows™ to run: it does not require BBC BASIC for Windows to be loaded, nor does it need any DLL files other than those supplied as standard with Windows. You can distribute such executables freely without any royalty for BBC BASIC being due.

The Compile command opens a dialogue box which allows you to choose the name of the executable file, select an appropriate icon, determine the initial window size and choose whether or not to 'crunch' or 'encrypt' the program:

Compile dialogue

Executable

The filename of the executable file is set by default to be the same as the name of your BASIC program, but with the extension '.exe' rather than '.bbc' (or '.bas'). However you can change the name and/or the directory path (folder) by typing them directly into the Filename field, by clicking on the Browse button or by using the REM!Exefile compiler directive.

(BBC BASIC for Windows version 5.00a or later only)
By default the executable file is stored in the exe subdirectory of the directory (folder) containing the BASIC program. This ensures that it is safe to run the executable file without any risk of embedded files, when extracted, overwriting wanted files in the source directory.

A default icon is used unless the specified executable file already exists, in which case the icon is taken from that file. You can change the icon by using the REM!Icon compiler directive or by clicking on the Change Icon button which calls up the Change Icon dialogue box:

Change Icon dialogue

You can choose an icon either from an existing executable file, or from a separate icon file (for example as produced by an icon editor). If a file contains a number of different icons, you can select the one you want to use. Please respect Copyright, and use only an icon which you have generated yourself or have legitimately obtained for this purpose.

(BBC BASIC for Windows version 5.00a or later only)
If the selected icon contains multiple variants with different resolutions (e.g. 16x16, 32x32, 48x48) and/or different colour depths (e.g. 16 colours, 256 colours) all the variants will be stored in the compiled executable file. The version used will be the one most suited to the current display settings. (This only works when BBC BASIC is running under Windows NT4.0™ or later; under Windows 95, 98 or Me a 32x32 16-colour icon is stored).

(BBC BASIC for Windows version 4.00a or later only)
You can choose to encrypt your program and any other embedded files (libraries, fonts, bitmaps etc.); this will make it very difficult for somebody to discover their contents by examining the executable file. However the encryption is not highly secure and you should not rely on it to protect sensitive data.

(BBC BASIC for Windows version 5.50a or later only)
You can choose to create a console application rather than a GUI application. A console application is intended to be run from a command prompt and usually won't have a visible window (with BBC BASIC for Windows a window is always created, but normally it will be hidden). To arrange that console input/output is used by your program it should have the following code near the beginning:

SYS "GetStdHandle", -10 TO @hfile%(1)
SYS "GetStdHandle", -11 TO @hfile%(2)
SYS "SetConsoleMode", @hfile%(1), 0
*INPUT 13
*OUTPUT 14
The program should exit (whether normally or as the result of an error) using QUIT, optionally followed by an exit code. You should always incorporate an ON ERROR statement since otherwise errors will be reported on the (hidden) output window and not be visible.

Appearance

You can set the initial width and height of your program's window, in pixels, by entering the appropriate values in the Compile dialogue box. There is little point in doing this if your program uses the MODE statement to initialise the screen, but otherwise it can be useful to set the window size to suit your application. A width or height value of zero causes Windows to select a default size.
(BBC BASIC for Windows version 3.00a or later only)
You can choose whether the dimensions you specify apply to the entire window or only to the client area, i.e. that region of the window used for BASIC's output. The latter will often be more useful.

The initial window state can be selected from the drop-down list as Hidden, Normal, Maximised or Minimised. If Maximised is selected, the program will start with the window as large as possible (irrespective of the specified width and height). If Minimised is selected, the program will start with no window (just an icon on the Taskbar). If Hidden is selected your program will neither have a visible window nor an icon in the Task Bar; this is useful for programs which operate in the background and for console mode programs. In all three cases you should normally avoid the use of the MODE statement in your program.

(BBC BASIC for Windows version 5.00a or later only)
You can enable the use of Windows XP™ Visual Styles by your compiled program. If this option is selected, and your program is run under Windows XP (with the default appearance settings), toolbars, status bars, dialogue boxes and other window furniture will have a more colourful and modern style. This selection also improves compatibility with Windows Vista™.

Crunch

You can choose to crunch your program when it is incorporated into the executable file. This reduces the size of the file, often by a significant amount, and increases the speed of execution of your program somewhat. It also makes it more difficult for somebody to discover how your program works. The following options are provided: When any of these options are selected, blank lines are also removed from your program.

When using the Remove REMs and Abbreviate names options you can include verbose comments in your program, and use long descriptive variable names, without the size or performance of the final compiled program being affected. In this way you can accord with good programming practice and make your 'source' program easier to understand and modify.

Although you can normally 'crunch' a program without it having any unwanted side effects, there are a few circumstances when it is incompatible with correct program operation:

If the crunch operation reports an error the offending statement will be highlighted.

Embedded files

If your program uses the INSTALL statement to load library modules, or loads other files at run time (such as graphics files, sound files, font files etc.) you must ensure that the files are available to the compiled program where it expects to find them. This is particularly important if you want to run the program on a computer on which BBC BASIC for Windows is not installed. You can achieve this by putting the files either in the library directory (as identified by the @lib$ system variable) or in the same directory as the program itself (as identified by the @dir$ system variable) and loading them as follows:
INSTALL @lib$+"LIBFILE.BBC"
OSCLI "PLAY """+@dir$+"MIDIFILE.MID"""
SYS "AddFontResource", @dir$+"BBCWIN.FON"
(BBC BASIC for Windows version 4.00a or later only)
Files loaded this way will automatically be incorporated into the compiled executable file and copied to appropriate locations on the target machine. Files in the library directory will be deleted from the target machine after the program has completed execution; files in the program's directory will be left there.

You can also manually edit the list of embedded files using the Add @dir$, Add @lib$ and Remove buttons. The Remove button deletes all selected (highlighted) entries in the list. You can select multiple files for addition and removal, using the Shift and Ctrl keys in the usual way (there is a limit to the number of files that can be added in one go, but more can be added by clicking on the Add button again). If the specified executable file already exists, the list of embedded files is read from that, so any previous edits will be remembered.

Note that it is not intended that this facility should substitute for a proper installer. If you need to do anything more complicated on installation than copying 'resource' files to the destination PC you should consider using an installer utility. For example see the free Inno Setup program.

In some cases it may be easier not to use INSTALL but simply to append the library modules onto the end of your program (using the File Insert command).

(BBC BASIC for Windows version 5.00a or later only)
You can choose to crunch embedded BBC BASIC (tokenised) program files, as well as the main program. If this option is selected any embedded files with a .BBC extension are crunched as if they were part of the main program. The same crunch options are used, and in the case of the abbreviate names option the same abbreviations are used. This ensures that any variables or structures shared between the main program and external modules, imported using INSTALL or CALL, will remain consistent. You must ensure that all imported library modules are embedded, otherwise function and procedure names will not be consistent (unless you use the REM!Keep compiler directive to prevent the names being abbreviated).

(BBC BASIC for Windows version 5.10a or later only)
Embedded files may come from the @dir$ or @lib$ folder, or a subfolder of either of these. When the executable program is run the necessary subfolder(s) will be created and the file(s) copied there. This can be useful if your program uses many resource files, perhaps sound files or bitmap files, and you prefer not to clutter up your program's folder with them. By creating subfolders called, for example, SOUNDS and IMAGES you can keep your files organised. In your program you could access these files as follows:

OSCLI "PLAY "+@dir$+"SOUNDS\TUNE1.MID"
OSCLI "DISPLAY "+@dir$+"IMAGES\PICTURE.BMP"

Compiler directives

(BBC BASIC for Windows version 5.50a or later only)
If an existing executable file, from a previous compilation, is found at the specified location it is used to initialise the compiler options. Alternatively you can incorporate compiler directives in your BASIC program, using specially formatted REM statements.

The compiler directives must be entered exactly as shown; they are case-sensitive. They may be included anywhere in your program. In the following list square brackets indicate optional parameters:

REM!Exefile filename[,encrypt][,console]
This directive allows you to specify the path and filename for the executable program, if it is different from the default. You can also optionally specify that the file contents should be encrypted, or that a console-mode executable should be created.
REM!Icon iconfile[,index]
This directive allows you to specify the file from which the executable's icon will be extracted. It may be either an icon (.ICO) file or an executable program (.EXE). In the case of a .EXE file, which can contain multiple icons, you can specify an optional index number (where zero is the first icon in the file).
REM!Window width,height[,client][,hidden][,minimised][,maximised][,xpstyle]
This directive allows you to specify the (initial) window dimensions, in pixels, and whether those dimensions apply to the entire window (the default) or the client area. You can also optionally specify the initial window state (hidden, minimised or maximised) and whether Windows XP visual styles should be used by the executable program.
REM!Crunch [spaces][,lines][,rems][,names][,embedded]
This directive allows you to specify whether the program will be crunched, and if so which crunch options are used. You can also specify that any embedded .BBC (program or library) files should also be crunched.
REM!Embed [file1][, file2...]
This directive allows you to specify which files should be embedded in the executable. The files must be specified in the form @dir$+"filename" or @lib$+"filename" (with no spaces). You may include more than one REM!Embed line if there are many such files, however you may not use wildcards.
REM!Keep var1[, var2, var3...]
This directive allows you to specify a list of variable, array or structure names which will not be abbreviated, even when the REM!Crunch names option has been selected. This is useful if you refer to named variables in a DATA statement or using EVAL but you still want to abbreviate the remaining variable names for best performance. Note that such variable names must have at least three characters (excluding the type character, if any) to minimise the risk that they will clash with one of the automatically-generated abbreviated names. You may include more than one REM!Keep line if there are many such variables.

(BBC BASIC for Windows version 5.60a or later only)
You can also specify that a procedure or function name should not be abbreviated:

REM!Keep PROCmyprocedure, FNmyfunction()
Note that in this context PROC and FN must be in capital letters, even if you use the Lowercase keywords option.

Apart from REM!Embed and REM!Keep it is not useful to have more than one directive of the same kind; if you do the one that is latest in the program will be used. Generally the REM!Exefile directive (if any) should be the first, since the other compiler options will be initialised from the contents of a previously-compiled file at the specified location, if present.

Here is an example set of compiler directives:

REM!Exefile C:\Documents and Settings\RTR\Desktop\index.exe
REM!Icon C:\Program Files\Help Workshop\hcw.exe, 1
REM!Window 640, 480, client, xpstyle 
REM!Crunch spaces, lines, rems, names, embedded
REM!Embed @dir$+"images\owl.bmp", @lib$+"WINLIB2"
REM!Keep header$, footer$


Options menu

Options menu Syntax Colouring Lowercase Keywords Indentation Toolbar Status Bar Set Font Set Colours Set Printer Font Customize

The options menu allows you to configure BBC BASIC for Windows to suit your own preferences. These preferences are saved on exit from BASIC, and are re-established whenever you run BBC BASIC in the future. The options menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-O.

Syntax Colouring

Clicking on Syntax Colouring toggles this feature on and off. When Syntax Colouring is enabled all the keywords, REMarks, text strings and line numbers in your program are highlighted in colour. You can change the colours by means of the Set Colours command.

When Syntax Colouring is disabled, all the program is listed in black.

Lowercase Keywords

Clicking on Lowercase Keywords toggles on and off the acceptance of BASIC keywords in lower-case letters. When this mode is enabled all keywords are listed in lower-case (both on the screen and on the printer). A keyword will be accepted on input from the keyboard, or from a file, either in all capital letters or in all lower-case letters. A word consisting of a mixture of upper and lower-case letters will never be mistaken for a keyword.

When Lowercase Keywords mode is disabled, keywords are only accepted in all capitals and are listed in capitals. This mode is the default and is compatible with earlier versions of BBC BASIC.

Indentation

Clicking on Indentation brings up the following sub-menu:

Indentation sub-menu

Selecting each of the options causes the appropriate program blocks to be indented (by two spaces) with respect to the surrounding code. This can make the program structure much clearer, and make it easier to spot mistakes.

Be aware that if you contrive to have (for example) two NEXT statements which match the same FOR statement, or vice versa, the resulting indentation will not be correct. In a well-structured program you would hopefully never do this anyway!

Toolbar

Clicking on Toolbar toggles the toolbar on and off. You can turn the toolbar off if you want to maximise the area available for the editing pane.

Status Bar

Clicking on Status Bar toggles the status bar on and off. You can turn the status bar off if you want to maximise the area available for the editing pane.

Set Font

The Set Font command allows you to select the font style and size for use in the editing pane. The command opens the Set Font dialogue box:

Set Font dialogue

Only those fonts which have a fixed pitch (i.e. monospaced fonts) can be used, and only suitable fonts are listed. The default font is the System Fixed Font, which is selected by ticking the Use System Fixed Font option.

Set Printer Font

(BBC BASIC for Windows version 4.00a or later only)
The Set Printer Font command allows you to select the font style and size used when you print your program using the Print command.

Only those fonts which have a fixed pitch (i.e. monospaced fonts) can be used, and only suitable fonts are listed. If no printer font has been selected the screen font is used (if the System Fixed Font has been selected a default printer font is used).

Set Colours

The Set Colours command allows you to select the colours which will be used for highlighting the various syntactical elements in your program (keywords, strings, remarks etc.), if the Syntax Colouring option has been enabled. The command opens the Set Colours dialogue box:

Set Colours dialogue

Selecting the appropriate syntactical element causes the current colour for that element to be identified by means of a box around the colour sample. You can change the colour for that element simply by clicking on the appropriate coloured rectangle, and then clicking on OK or Apply (OK closes the dialogue box, whereas Apply leaves it open so that further changes can be made).

If the selection of 48 pre-defined colours is not sufficient, you can click on Define Custom Colour which allows you to choose a colour from the full range supported by your video hardware and settings.

Customize

(BBC BASIC for Windows version 4.00a or later only)
The Customize command allows you to customize certain settings according to your personal preferences. The command opens the Customize dialogue box:

Customize dialogue

The Default program box allows you to enter the name of a BASIC program which will be automatically loaded every time BBC BASIC for Windows is started. To ensure that this works correctly whatever the current (Start in) directory, you should enter the full path to the program file (the box will scroll horizontally as required). Alternatively you can browse for the file by clicking on the button with three dots.

The Initial user memory box allows you to set the amount of memory available for loading your BASIC programs (it also determines the initial value of HIMEM when a program is run). The default value is one Megabyte (1048576 bytes) which should be large enough for all but the very largest programs. Increasing this value more than necessary will cause BBC BASIC for Windows to use extra memory and may affect performance if insufficient RAM is fitted in your PC. For a change to take effect you must exit and re-start BBC BASIC.

The Number of undo levels setting determines how many editing operations you can reverse with the Undo command. Increasing this value can result in BBC BASIC for Windows using up much more memory and may affect performance if insufficient RAM is fitted in your PC.

The Accept keyword abbreviations setting controls whether the program editor will accept keyword abbreviations such as P. instead of PRINT. One reason why you might want to turn off this facility is that structure names may be mistaken for abbreviated keywords.

The Maximum number of columns setting determines the maximum width of the right-click context menu. You should set it so the menu always fits on your screen, with the display resolution you are using.

The Maximum number of rows setting determines the maximum height of the right-click context menu. You should set it so the menu always fits on your screen, with the display resolution you are using.

The Include ON statements setting controls whether ON CLOSE, ON ERROR, ON MOUSE, ON MOVE, ON TIME and ON SYS statements appear in the right-click context menu. In any case they only appear when at the very beginning of a program line.


Run menu

Run menu Run Stop Pause Step Step Line Run To Cursor Immediate Mode

The run menu is concerned with running and debugging your BBC BASIC program. The run menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-R.

Run  

The Run command (keyboard shortcut F9) executes the BASIC program currently in memory. It opens a new window where any output from the program appears, and into which you type any keyboard input the program requires. Error messages also appear in this window. If there is no program currently in memory, Run has the same effect as the Immediate command.

If the program is already running (i.e. its output window is open), Run stops the program and restarts it from the beginning (note the caveat listed under Stop about any ON CLOSE routine not being executed).

(BBC BASIC for Windows version 3.00a or later only)
If the line numbers (if any) in your program are not in ascending sequence, an error message is displayed and the first out-of-sequence line number is highlighted. You must correct the line numbers, for example by using the Renumber utility, before you can run the program.

Stop  

The Stop command stops the program currently running and closes its window. Stop will normally close the program immediately, whatever it is doing, but if your program is waiting for a Windows API (SYS) function to return, or is executing some assembler code, this may delay the response.

Note that any ON CLOSE routine in your program will not be executed. It is therefore better to use the normal methods of ending your program (e.g. clicking on the Close button) when possible and to use the Stop command only as a last resort.

If the program is not currently running (i.e. its output window is not open) the Stop command is inhibited.

Pause  

The Pause command (keyboard shortcut F8) pauses the currently-executing BASIC program at the start of the next statement. If the program is currently waiting for input (e.g. is executing a GET or INPUT statement) it will enter the paused state once the input has been provided. When paused, the program will produce no output nor accept any input (keypresses will still be put in the keyboard buffer). You can find out where the program has paused with the Trace command and/or examine the current values of the program's variables with the List Variables command.

If the program is not currently running (i.e. its output window is not open) the Pause command is inhibited.

Step  

The Step command (keyboard shortcut F7) allows you to single-step a paused program, one statement at a time. You can monitor the execution of the program with the Trace command and/or follow the changing values of the program's variables with the List Variables command.

If the program is not currently paused, the Step command is inhibited. If you want to single-step through only a specific part of your program, add an input statement (e.g. X=GET) at that point so you can pause the program while it is waiting for input; once the Pause command has been issued you can then enter the paused state by pressing a key. Alternatively use the Run To Cursor command.

Step Line

(BBC BASIC for Windows version 5.60a or later only)
The Step Line command (keyboard shortcut F5) is similar to the Step command except that all the remaining statements in the current line (and the first statement in the next line) are executed before pausing. This is particularly useful in allowing you to 'step over' a procedure or function call without having to single-step through all its statements, or to 'step out' of a loop without having to single-step through every iteration.

If the program never executes a statement in the next line, it will not pause.

Run To Cursor

(BBC BASIC for Windows version 4.00a or later only)
The Run To Cursor command (keyboard shortcut F6) behaves the same as the Run command except that the program automatically pauses (as if the Pause command was issued) when it reaches the line containing the text cursor (caret). This is useful if you need to single-step through part of the program but don't want to start at the beginning.

The first (or only) statement in the line containing the cursor is executed before the program pauses. If the program never executes a statement in the line containing the cursor, it will not pause. Once the program is paused, issuing the Run To Cursor command again (or pressing F6) will cause execution to continue from that point; the program will pause again if there are more statements in the line, or if the line is reentered later.

Note that the program will not pause on any of the following lines:

Immediate Mode  

The Immediate Mode command opens the output window but does not execute the BASIC program; instead the BASIC command prompt is displayed. At this prompt you can type BASIC statements which are executed immediately on pressing Return (Enter). For example you can use this facility as a calculator by typing PRINT followed by a sum:
>PRINT 2+2
Immediate Mode can also be useful for doing things like deleting a file (*DELETE), or setting a file to read-only status (*LOCK). When in immediate mode you can execute the current program by typing RUN. If the current program is already running (i.e. its output window is open) the Immediate command will stop the program before entering immediate mode.


Help menu

Help menu Help Topics Tutorial Email Website Discussion Group Wiki About BBC BASIC

The help menu gives access to the BBC BASIC for Windows documentation, provides links to information via email or from the web, and displays version information. The help menu can be accessed by clicking on its name in the menu bar or by means of the keyboard shortcut Alt-H.

Help Topics

The Help Topics command calls up the main help window, from which you can browse or search the BBC BASIC for Windows Help documentation. This command can also be accessed by pressing F1.

Tutorial

The Tutorial command opens the beginners' tutorial in a separate window.

Email

The Email command calls up your default mail program (if any) so that you can send a message to request help or information about BBC BASIC.

Website

The Website command calls up your default web browser (if any) and automatically directs it to the R.T.Russell home page.

Discussion Group

The Discussion Group command takes you to the BB4W Yahoo!™ group, where you can meet like minded people who can provide help and advice on using BBC BASIC for Windows.

Wiki

The Wiki command takes you to the BB4W Programmers' Reference Wiki. This is an ever-growing resource of articles on all aspects of programming in BBC BASIC for Windows.

About BBC BASIC

The About command displays the version number of BBC BASIC for Windows and (in the case of the full version) your personal serial number.


The editing pane

The editing pane is where the BASIC program currently loaded into memory (if any) is displayed for viewing or editing, or where a new program is entered. Most of the normal features which you expect from a Windows™ editor are available. You can manipulate and edit the program using the keyboard and the mouse.

Keyboard commands

The following operations are available using the keyboard:

KeyOperation
Insert Toggle between insert and overtype mode. In overtype mode any character typed will over-write the existing character at that position on the line. In insert mode any character typed will 'push' the rest of the line to the right to make room. The insert/overtype status is indicated in the status bar.
Delete This key has an identical effect to the Delete command. If any text is selected (highlighted) it is deleted, without being copied to the clipboard. Otherwise, the character to the immediate right of the cursor (caret) is deleted and the rest of the line is moved left to fill the gap.
Home Move the cursor (caret) to the start of the current program line, and scroll the display horizontally (if necessary) to ensure that the cursor is visible.
Ctrl+Home Move the cursor (caret) to the start of the program, and scroll the display horizontally and/or vertically (if necessary) to ensure that the cursor is visible.
End Move the cursor (caret) to the end of the current program line, and scroll the display horizontally (if necessary) to ensure that the cursor is visible.
Ctrl+End Move the cursor (caret) to the end of the program, and scroll the display horizontally and/or vertically (if necessary) to ensure that the cursor is visible.
Page Up Display the previous 'page' of the program by scrolling the display down by one screenful (less one line) or until the first line of the program is visible, whichever is less. If the first line of the program is already in view, Page Up has no effect.
Page Down Display the next 'page' of the program by scrolling the display up by one screenful (less one line) or until the last line of the program is visible, whichever is less. If the last line of the program is already in view, Page Down has no effect.
Left Move the cursor (caret) one character to the left, and scroll the display horizontally (if necessary) to ensure that the cursor remains visible. If Shift is held down, select (or de-select) a character. If the cursor is already at the beginning of a line, the key has no effect.
Right Move the cursor (caret) one character to the right, and scroll the display horizontally (if necessary) to ensure that the cursor remains visible. If Shift is held down, select (or de-select) a character.
Up Move the cursor (caret) up one line, and scroll the display vertically (if necessary) to ensure that the cursor remains visible. If Shift is held down, select (or de-select) a line. If the cursor is already on the first line, the key has no effect.
Down Move the cursor (caret) down one line, and scroll the display vertically (if necessary) to ensure that the cursor remains visible. If Shift is held down, select (or de-select) a line. If the cursor is already on the last line, the key has no effect.
Backspace Delete the character immediately to the left of the cursor (caret), and move the cursor left one position. The rest of the line, to the right of the cursor, is moved left to fill the gap. If the cursor is at the beginning of a line, delete the preceding 'new line' (and the line number, if any) and concatenate the contents of the present line onto the end of the previous line.
Return (Enter) Insert a 'new line' at the current position of the cursor (caret). Everything to the right of the cursor will be moved onto the next line, and the rest of the program is moved down one line to make space. By this means you can split an existing line into two or more lines
Ctrl+Left (BBC BASIC for Windows version 3.00a or later only)
Move the cursor (caret) one word to the left, and scroll the display horizontally (if necessary) to ensure that the cursor remains visible. If Shift is also held down, select (or de-select) a word.
Ctrl+Right (BBC BASIC for Windows version 3.00a or later only)
Move the cursor (caret) one word to the right, and scroll the display horizontally (if necessary) to ensure that the cursor remains visible. If Shift is also held down, select (or de-select) a word.

The 'printing' keys (letters, numbers and symbols) cause the appropriate character to be entered at the position of the cursor (caret), and the cursor is then moved right by one position. If anything is selected (highlighted) when the key is pressed, it is first deleted.

Mouse commands

The following operations are available using the mouse:

ActionOperation
Left click Clicking in the editing pane with the left mouse button causes the text cursor (caret) to be moved to the character position nearest to the mouse pointer. If Shift is held down, the region between the previous position of the text cursor and the new position will be selected. If Ctrl is held down the entire line containing the text cursor will be selected.
Left double-click Double-clicking in the editing pane with the left mouse button causes the word under the mouse pointer (and the following space, if any) to be selected. The text cursor (caret) is moved to the end of the selected region. The selected word can then be cut, copied or deleted. If the Find or Replace command is issued, the selected word is copied to the Find What field.
Left drag Holding down the left mouse button and 'dragging' the mouse pointer over the program displayed in the editing pane causes a section of the program to be selected. Dragging the mouse horizontally selects part or all of a line; dragging the mouse vertically selects a block of lines (only entire lines may be selected).
Right click Clicking in the editing pane with the right mouse button causes the Context Menu to be displayed.

Drag and Drop

(BBC BASIC for Windows version 2.00a or later only)
If you move the mouse pointer over a selected (highlighted) region of your program, the pointer shape changes to an arrow. In this situation holding down the left mouse button and 'dragging' the mouse pointer initiates a Drag and Drop operation. If you drag the mouse pointer to a different point in your program (outside the selected region), and then release the left button, the selected text will be deleted from its original place and inserted where the button was released. This is equivalent to a cut-and-paste operation via the clipboard.

Alternatively, if you hold down the Ctrl key before releasing the left button the selected text is copied to the location where the button was released (a plus sign appears next to the mouse pointer indicating a copy rather than a move). This is equivalent to a copy-and-paste operation via the clipboard. If you want to cancel the Drag and Drop operation you can do that by presing the ESCape key before you release the left button, or by releasing the button when the pointer is inside the selected area.

You can also Drag and Drop between BBC BASIC for Windows and any other program supporting that facility. You will often find that a plus sign is shown next to the mouse pointer, even if you are not holding down the Ctrl key. That signifies that you cannot delete the text in the window from which you are dragging it (for example if you drag program examples from the BBC BASIC for Windows Help window).

Context Menu

Clicking in the editing pane with the right mouse button causes the 'floating' context menu to be displayed at the position of the mouse pointer. The context menu contains one or more of the following items: You can also access the context menu by pressing Shift+F10.

Scroll bars

If the current program cannot be displayed in its entirety within the editing pane, vertical and/or horizontal scroll bars are displayed. These allow you to scroll the display until the part of the program in which you are interested is in view. The scroll bars can be operated in one of four ways:

Left CONTENTS

CONTINUE Right


Best viewed with Any Browser Valid HTML 3.2!
© Richard Russell 2008