The VDU statement takes a list of numeric arguments (constants or variables) and sends their least significant bytes as characters to the currently selected output stream.
A 16 bit value (word) can be sent if the value is followed by a semi-colon. It is sent as a pair of characters, the least significant byte first.
Number | Meaning |
---|---|
0 | Null - it does nothing. |
1 | Send the next character to the printer ONLY. |
2 | Enable the printer. |
3 | Disable the printer. |
4 | Write text at the text cursor position. |
5 | Write text at the graphics cursor position. |
6 | Enable output to the screen. |
7 | Bell - make a short 'beep'. |
8 | Move the text cursor backwards one character. |
9 | Move the text cursor forwards one character. |
10 | Move the text cursor down one line. |
11 | Move the text cursor up one line. |
12 | Clear the text area - identical to CLS. |
13 | Move the text cursor to the start of the current line. |
14 | Enable the auto-paging mode. |
15 | Disable the auto-paging mode. |
16 | Clear the graphics area - identical to CLG. |
17 | Define a text colour - identical to COLOUR. |
18 | Define a graphics colour - identical to GCOL. |
19 | Select a colour palette. |
20 | Restore the default logical colours. |
21 | Disable output to the screen. |
22 | Select the screen mode - identical to MODE. |
23 | Create user-defined characters and screen modes, etc. |
24 | Define a graphics viewport. |
25 | Identical to PLOT. |
26 | Restore the default text and graphics viewports. |
27 | Send the next character to the screen. |
28 | Define a text viewport. |
29 | Set the graphics origin - identical to ORIGIN. |
30 | Home the text cursor to the top left of the screen. |
31 | Move the text cursor - identical to TAB(x,y). |
127 | Backspace and delete. |
VDU 0
VDU 1 provides a simple way of sending single characters to the printer driver. It works whether the VDU has been disabled with the VDU 21 command or not. For example VDU 1,12 will send a 'form feed' and force the current page to be printed.
Note that you should not attempt to send printer-specific control characters (e.g. for setting the font, style etc.) as this won't work. BBC BASIC for Windows uses the Windows™ printer drivers and changes to the font or style must be made with the *PRINTERFONT command.
VDU 1,12
The following control characters are acted upon by the printer: cursor left (VDU 8), cursor right (VDU 9), cursor down (VDU 10), cursor up (VDU 11), form feed (VDU 12), carriage return ( VDU 13) and home (VDU 30).
Bytes which are parameters for VDU commands are not sent to the printer. For example,
does not send 'A' (CHR$65) to the printer.VDU 17,65
If you need to line up columns on the printer using TAB(X) ensure you select a monospaced (fixed-pitch) font, for example:
Note that BBC BASIC for Windows assumes that the printer is a page printer. That is, output will not be printed until the current page is complete (i.e. a CLS or VDU 12 was sent, or the BASIC program terminates). This ensures that printer output is not mixed up with that from other programs running at the same time. You can force the current page to print using:*PRINTERFONT Courier New,12
VDU 2,1,12,3
VDU 3 VDU 2,1,12,3
Characters can be positioned only at text coordinates within the text viewport; the text viewport scrolls as necessary. Characters are written using the current text foreground colour on an opaque background of the current text background colour (see COLOUR).
VDU 4
Characters may be positioned at any graphics coordinate within the graphics viewport. The top left corner of the character cell is the reference point. Characters are clipped to the limits of the graphics viewport if necessary. No scrolling takes place.
Characters are plotted using the current graphics foreground colour and in the current graphics foreground plotting mode (see GCOL).
The character background is 'transparent', i.e. it does not change what was previously displayed underneath. VDU 127 (DEL) is an exception; it backspaces and deletes just as it does in the normal text mode, using the current background GCOL rules and colour.
VDU 5
VDU 6
VDU 7
VDU 8
VDU 9
VDU 10
VDU 11
VDU 12 VDU 2,1,12,3
VDU 13
VDU 14
VDU 15
VDU 16
VDU 17,1
andVDU 18,mode,colour
have the same effect. See the Graphics and colours section for more details.GCOL mode,colour
VDU 19 takes the next five characters as parameters. The first parameter is the logical colour to be set and the remaining parameters determine the physical colour that it is to be set to.
If the second parameter is in the range 0 to 15 this determines the physical colour as an offset into the physical palette, in this case the remaining three parameters are ignored.
VDU 19,logical,physical,0,0,0
If the second parameter is −1 (or 255) the physical colour is determined by interpreting the remaining three parameters as red, green and blue values in the range 0 to 63, where 0 is none and 63 is maximum.
VDU 19,logical,-1,r,g,b
If the second parameter is 16 the physical colour is determined by interpreting the remaining three parameters as red, green and blue values in the range 0 to 255, where 0 is none and 255 is maximum.
VDU 19,logical,16,R,G,B
COLOUR 7 COLOUR 128 GCOL 0,7 GCOL 0,128
FOR N = 0 TO 15 VDU 19,N,N,0,0,0 NEXT N
VDU 20
VDU 21
VDU 22 also resets all the screen driver variables (colour, palette, viewports, cursor position, graphics origin, etc). In particular, VDU 22 performs the actions of VDU 4, VDU 12, VDU 15, VDU 20 and VDU 26.VDU 22,3
See the Graphics and colours section and the keyword MODE for further details.
VDU 22,mode
The format of the VDU 23 command is;
'Char_no' is the character number to be programmed and 'r1' to 'r8' are the values of the bytes which define the character, top to bottom. For example, the character illustrated below is defined as character 130 by the following VDU 23 command.VDU 23,char_no,r1,r2,r3,r4,r5,r6,r7,r8
User defined characters occupy a 'cell' which is 8 dots wide by 8 dots high. The number of rows of user defined text which may be displayed on the screen depends on the vertical resolution of the display mode in use.VDU 23,130,32,98,226,62,62,35,33,33 . . * . . . . . r1 = 32 . * * . . . * . r2 = 98 * * * . . . * . r3 = 226 . . * * * * * . r4 = 62 . . * * * * * . r5 = 62 . . * . . . * * r6 = 35 . . * . . . . * r7 = 33 . . * . . . . * r8 = 33
Note that although the current character font can be changed to any size using the *FONT command, user-defined characters are always the same size in a particular display MODE.
The shape of the text cursor can be controlled (to some degree) by using VDU 23 to set the start line and end line of the cursor 'block'; this affects its height and vertical position. The 'start line' and 'end line' are controlled by the following commands:VDU 23,1,0;0;0;0; : REM Disable cursor VDU 23,1,1;0;0;0; : REM Enable cursor
For example, the text cursor is normally a flashing underline in 'insert' mode and a flashing block in 'overtype' mode. To turn it from an underline into a block without changing to 'overtype' mode you can use the following command:VDU 23,0,10,s,0;0;0; : REM Set start line VDU 23,0,11,e,0;0;0; : REM Set end line
This facility should be used with care.VDU 23,0,10;0;0;0;
The width of the text cursor can also be set:
This sets the width of the cursor to w pixels. If w is zero (the default) the cursor is set to the average character width of the current font.VDU 23,0,18,w,0;0;0; : REM Set cursor width
For example, to set the cursor to a vertical line two pixels wide use the following code:
VDU 23,0,18,2,0;0;0;23,0,10;0;0;0;
where m and d are as follows:VDU 23,7,m,d,0;0;0;
m = 0 | scroll just the text viewport |
m = 1 | scroll BASIC's entire output window |
d = 0 | scroll right one character |
d = 1 | scroll left one character |
d = 2 | scroll down one row |
d = 3 | scroll up one row |
where:VDU 23,22,width;height;charx,chary,ncols,charset
width = window width in pixels (e.g. 640)Note that the width and height values must be followed by semicolons. You should choose the width and height values to be integer multiples of the charx and chary values respectively. For example, you can select a mode which has 10 (large!) characters per line and 8 lines of text as follows:
height = window height in pixels (e.g. 512)
charx = character width in pixels (e.g. 8)
chary = character height in pixels (e.g. 16)
ncols = number of colours (e.g. 16)
charset = 0 for ANSI, 1 for OEM (IBM PC), 8 for UTF-8
The maximum values for width and height are 1920 and 1440 respectively.VDU 23,22,640;512;64,64,16,0
By default the background colour is black and the text colour is white. To select a mode with a white background and black text add 128 to the charset value.
If the charset value is set to 8, text output to the screen or printer is assumed to be in UTF-8 format. This gives access to the complete Basic Multilingual Plane (including alphabets like Greek, Cyrillic, Arabic, Hebrew etc.) whilst remaining compatible with ASCII. To utilise this mode you should select a Unicode font after the VDU 23 command:
VDU 23,22,640;512;8,16,16,8 *FONT Arial,16
where t is the required line thickness in pixels. Note that only solid lines can have their thickness changed, not dotted or dashed lines.VDU 23,23,t;0;0;0; or VDU 23,23,t|
where the existing 8-bit flags byte is first ANDed with y and then exclusive-ORed with x. To set the entire flags byte to the value f you can do:VDU 23,16,x,y,0;0;0;
The flag bits control the cursor movement as follows (bit 7 must be zero):VDU 23,16,f;0;0;0; or VDU 23,16,f|
Bits 1, 2 and 3 affect the column and row addressing used by TAB(X,Y), POS and VPOS. The default value of all the bits is zero.
Flag bit Action Bit 6 = 0 The text cursor is constrained to remain within the viewport/page (e.g. by wrapping or scrolling). Bit 6 = 1 The text cursor can move beyond the edge of the viewport/page (except in VDU 4 mode). Bit 5 = 0 The text cursor moves after a character is output. Bit 5 = 1 The text cursor does not move after a character is output. Bit 4 = 0 If appropriate the text viewport scrolls, or the printer page is ejected. Bit 4 = 1 The text cursor wraps to the opposite edge of the viewport/page. Bit 3 = 0 The 'X' direction is horizontal and the 'Y' direction is vertical. Bit 3 = 1 The 'X' direction is vertical and the 'Y' direction is horizontal. Bit 2 = 0 The 'positive' vertical direction is downwards. Bit 2 = 1 The 'positive' vertical direction is upwards. Bit 1 = 0 The 'positive' horizontal direction is rightwards. Bit 1 = 1 The 'positive' horizontal direction is leftwards. Bit 0 = 0 In VDU 4 mode, 'pending scroll' is enabled. Bit 0 = 1 In VDU 4 mode, 'pending CRLF' is enabled.
In 'pending scroll' mode, if a character would normally cause the text viewport to scroll (thus causing the top line to be lost) it will not do so until just before the next character is output. If the cursor is repositioned (e.g. using VDU 13, VDU 30 or VDU 31) before the next character is output, no scroll will take place.
In 'pending CRLF' mode, if a character would normally cause a CRLF action (the text cursor wrapping to the beginning of the next line) it will not do so until just before the next character is output. If the cursor is repositioned before the next character is output, no CRLF will take place.
It is particularly easy to select invalid viewport limits if the graphics origin has been moved. It is advisable, therefore, to precede a VDU 24 command with a VDU 29,0;0; command or ORIGIN 0,0 statement to reset the graphics origin.
The following example defines a graphics viewport with the bottom left corner at 200,100 and the top right corner at 500,300.
VDU 24,200;100;500;300;
Be very careful not to omit the final semicolon.VDU 24,left;bottom;right;top;
The following example draws a line in the current foreground colour to the point 350,525:VDU 25,mode,x_coord;y_coord;
VDU 25,5,350;525;
Important note: VDU 26 resets the text and graphics viewports to the current size of BASIC's screen (output window), not to the default size appropriate to the current MODE. In the event that BASIC's output window has been resized by the user (by dragging a corner or side) or has a reduced size because the display resolution is inadequate for the selected MODE, VDU 26 may alter the relative alignment of text and graphics. If this could be a problem, avoid the use of VDU 26 (or make sure the display resolution is sufficient and prevent the user resizing the window).
VDU 26
VDU 27,127
If the text cursor is outside the new viewport, it is moved to the new home position (top left of the viewport). If it is inside the new viewport, it is not moved.
The following example defines a text viewport with the bottom left corner at X=0, Y=15 and the top right corner at X=30, Y=3 .
VDU 28,0,15,30,3
VDU 28,left,bottom,right,top
The following example sets the graphics origin to 640,400:
VDU 29,640;400; ORIGIN 640,400
VDU 30
See the keyword TAB for further details.VDU 31,15,10
VDU 31,col,row
VDU 127
File and directory names are not case-sensitive and generally do not need to be enclosed in quotes. However if a file or directory name includes any spaces (or punctuation characters) you must enclose it in quotes; unmatched quotes will cause a 'Bad string' error. If you need to use the OSCLI statement there are two main ways of incorporating quotation marks, with CHR$(34) or using the 'escape' sequence "". For example both the following will work:[drive:][\][path\]filename[.ext]
drive: The single letter name of the drive where the file will be found. The colon is mandatory. If the drive name is omitted, the current drive is assumed. path The list of directories and sub-directories (folders) which must be followed in order to find the specified file. The names of each directory in the path must be separated by the backslash character. If the path is omitted, the current directory on the specified drive is assumed. filename The name of the file. If this contains spaces the entire file specifier should be enclosed in quotation marks (see below). ext The optional extension of the file. If an extension is used it must be separated from the filename by a full-stop. If the extension is omitted, .BBC is (usually) assumed.
OSCLI "CD "+CHR$(34)+directory$+CHR$(34) OSCLI "CD """+directory$+""""
When an 'ambiguous' file specifier is needed the standard wildcard characters (? and *) may be used.
Control characters, DEL, quotation marks and other special characters may be incorporated in filenames etc. by using the 'escape' character '|', however the host operating system (e.g. Windows™) may not accept them:
|A gives ^A (control A). |? gives Del. |" gives the quotation mark ". || gives the escape character |. |! sets bit 7 of the following character.
A star command must be the last (or only) command on a program line and its argument may not be a variable. Unlike keywords, star commands are not case-sensitive (and are not affected by *LOWERCASE).*HELP OSCLI("HELP")
will execute BBC BASIC for Windows' resident file copy command but*COPY
will pass the command to Windows™.**COPY
For this reason, the *FX (with the exception of *FX 15 and *FX 21) and *TV commands are trapped and ignored. These two star commands are commonly found in programs for the BBC Micro, but they have no counterpart in Windows™.
Command | Function |
---|---|
*BYE | exit the BASIC program and close its window |
*CHDIR (*CD) | display or change the current directory |
*COPY | copy a file |
*DELETE (*DEL) | delete a file |
*DIR (*.) | list the directory contents |
*DISPLAY | display a Windows Bitmap (BMP) file |
*EGA | emulate an EGA or CGA display |
*ERASE (*ERA) | delete a file |
*ESC | enable or disable the Escape key |
*EXEC | accept console input from a file |
*FLOAT | select floating-point numeric precision |
*FONT | select a screen font and style |
*FX | flush keyboard and/or sound buffers |
*GSAVE | synonymous with *SCREENSAVE |
*HARDCOPY | copy graphics to the printer |
*HELP | display version information |
*HEX | control hexadecimal conversion and shift operators |
*INPUT | redirect console input |
*KEY | program a function or special key |
*LIST | display the contents of a program file |
*LOAD | load a file into memory |
*LOCK | set a file to read-only status |
*LOWERCASE | enable or disable lower-case keywords |
*MARGINS | set the printer page margins |
*MKDIR (*MD) | create a sub-directory (folder) |
*MDISPLAY | display a BMP image stored in memory |
*NOEGA | cancel the effect of *EGA |
*OUTPUT (*OPT) | redirect console output |
*PLAY | play a MIDI file |
*PRINTER | select a printer |
*PRINTERFONT | select a printer font and style |
*QUIT | exit the BASIC program and close its window |
*REFRESH | control when the screen is refreshed |
*RENAME (*REN) | rename a file |
*RMDIR (*RD) | remove (delete) a directory |
*RUN | execute a Windows GUI or Console command |
*SAVE | save memory to a file |
*SCREENSAVE | save the output window as a BMP file |
*SPOOL | copy console output to a file |
*SPOOLON | append console output to an existing file |
*SYS | enable trapping of additional system messages |
*TEMPO | control the speed of the SOUND statement |
*TIMER | control the periodicity of the ON TIME interrupt |
*TV | accepted but ignored |
*TYPE | display the contents of a text file |
*UNLOCK | set a file to read-write status |
*| | a comment |
If the BASIC program is running stand-alone (either using the BBCWRUN utility or having been converted to an executable with the Compile command) the program quits and returns control to Windows™
*BYE is synonymous with the *QUIT command and the QUIT statement.
*BYE
*CD followed only by a backslash will change the current working directory to the root (top level) directory of the current drive. *CD followed only by a drive name will change the current working directory to the root directory of that drive.*CHDIR BBCBASIC\DOC *CD A:\LETTERS\RATES *CD "Program Files" OSCLI "CD """+directory$+""""
*CD on its own will display the current working directory (folder). If your program needs to know the current directory you can either use *CD and SPOOL the output to a file, or you can use the GetCurrentDirectory API function:*CHDIR \ *CD A:
DEF FNcurrentdirectory DIM cd% LOCAL 255 SYS "GetCurrentDirectory", 256, cd% = $$cd%
*CD [d:][\][pth] *CHDIR [d:][\][pth]
If the summed lengths of the source and destination filenames exceeds 254 characters a String too long error will result. In that case you can use the Windows™ API instead (the extensions must be included explicitly):*COPY srcfile.dat destfile.dat OSCLI "COPY """+sourcefile$+""" """+destfile$+""""
The above commands will copy only one file at a time; wildcards are not permitted in the file specifiers. If you wish to include wildcards in order to copy more than one file, you can use the **COPY command which will be executed by Windows™. Alternatively you can use the following routine based on the FindFirstFile and FindNextFile Windows™ API functions:SYS "CopyFile", sourcefile$, destfile$, 0
The parameters are the source and destination directories and a file specification containing wildcards (* or ?).DEF PROCcopyfiles(src$,dst$,afsp$) LOCAL dir%, buf%, sh%, res%, fpt%, num% DIM dir% LOCAL 317, buf% LOCAL 260 IF RIGHT$(src$,1) <> "\" src$ += "\" IF RIGHT$(dst$,1) <> "\" dst$ += "\" SYS "FindFirstFile", src$+afsp$, dir% TO sh% IF sh% <> -1 THEN REPEAT SYS "GetFullPathName", dir%+44, 260, buf%, ^fpt% TO num% buf%?num% = 13 IF (!dir% AND 16) = 0 THEN SYS "CopyFile", src$+$fpt%, dst$+$fpt%, 0 TO res% IF res% = 0 PRINT "File copy failed" ENDIF SYS "FindNextFile", sh%, dir% TO res% UNTIL res% = 0 SYS "FindClose", sh% ENDIF ENDPROC
*COPY ufsp ufsp
This command will delete only one file at a time; a wildcard is not permitted in the file specifier. If you wish to include wildcards in order to delete more than one file, you can use the **DEL command which will be executed by Windows™. Alternatively you can write your own routine based on the FindFirstFile and FindNextFile Windows™ API functions.*DEL GAME1.DTA OSCLI "DEL """+file$+""""
*DEL ufsp *DELETE ufsp
*DIR |
*. |
*DIR List all .BBC files in the current directory (folder). *DIR B:*.* List all files on disk B. *.*.* List all the files in the current directory.
*DIR [afsp]
The specified position (x,y) corresponds to the bottom-left corner of the image, and is given in BBC BASIC for Windows graphics units. The size and shape of the image may optionally be specified, in which case the image is scaled as necessary; this may result in a loss of quality. If the width and height are omitted the image is displayed without scaling.*DISPLAY bmpfile *DISPLAY bmpfile x,y *DISPLAY bmpfile x,y,w,h OSCLI "DISPLAY """+bmpfile$+""" "+STR$x+","+STR$y+","+STR$w+","+STR$h
The quality of the displayed image will be affected by your current display settings (right-click on the desktop, select Properties then Settings). For best results ensure you are using High Colour (16-bit) or True Colour (24-bit), but see the Compatibility limitations section for notes on the effects of the different settings.
The position and size values must be integers; if necessary use the INT function to ensure there is no decimal point.
If the filename extension is omitted, .BMP is assumed. See also *MDISPLAY and *SCREENSAVE.
When the image is scaled, you may find that the quality is improved by preceding the *DISPLAY command with the following statement:
SYS "SetStretchBltMode", @memhdc%, 3
BBC BASIC for Windows version 6.10a or later, or BBCSDL, only
An additional parameter may be specified, corresponding to a hexadecimal value
that will be interpreted as a 'transparent' or 'key' colour; any pixels with this colour
in the image will not be plotted and whatever was 'behind' will show through (requires
Windows 2000 or later):
The key colour must be specified in whatever format the BMP file uses internally, so if it's a 24 bits-per-pixel RGB file specify a six-digit hexadecimal value in the format rrggbb (if the key colour is black specify it as 1000000). If the file has a different pixel format specify it in whatever representation the file uses. In the special case of a 16 bits-per-pixel file ensure that you choose a key colour which has low RGB values, for example R=1, G=1, B=1 which corresponds to the hexadecimal value 0421 in a RGB555 file.OSCLI "DISPLAY """+bmpfile$+""" x,y,w,h,k"
BBC BASIC for Windows version 6.11a or later, or BBCSDL, only
If you specify the width and/or height as negative values the image will be automatically
flipped: horizontally, vertically or both. The specified position still corresponds to the bottom-left
corner of the original (unflipped) image. This feature does not work if the 'transparent'
or 'key' colour option is used.
*DISPLAY ufsp [num,num[,num,num[,hex]]]
*EGA OFF causes screen modes 0 to 15 to be mapped to the dimensions and number of colours they would have in BBC BASIC (86) when the *EGA command is not used (or the *EGA OFF command is used), i.e. modes of which a CGA adaptor and monitor are capable.
BBC BASIC (86) programs which include a *EGA (or *EGA ON) command should therefore select an appropriate mode without needing to be modified. BBC BASIC (86) programs which don't include a *EGA command should be modified by adding a *EGA OFF command. This will cause BBC BASIC for Windows to select an appropriate mode, but will not affect the operation of the program in BBC BASIC (86).
If you need to cancel the effect of *EGA, use *NOEGA.
*EGA ON *EGA OFF *NOEGA
*EGA [ON|OFF]
*ERASE ufsp
After *ESC OFF the <Esc> key simply returns the ASCII code for ESCape (27). *ESC ON (or *ESC) restores the normal abort action of the <Esc> key.*ESC OFF *ESC ON
*ESC [ON|OFF]
Once the entire file has been read, keyboard input is restored. *EXEC without a filename closes the file and restores keyboard input immediately.*EXEC STARTUP.CMD OSCLI "EXEC """+cmdfile$+""""
*EXEC [ufsp]
The *FLOAT command affects the precision with which floating-point values are stored and retrieved using floating-point indirection or in data files (PRINT# and INPUT# statements). When reading or modifying a data file you should always use the same *FLOAT mode as when it was originally written.*FLOAT 40 *FLOAT 64 *FLOAT 80
BBC BASIC for Windows version 5.95a or earlier only
The *FLOAT command additionally controls the precision of variant
(suffixless) numeric variables; only *FLOAT40 (the default) and *FLOAT 64 are available.
In *FLOAT40 mode variant (real) numbers have approximately a 9 significant-figure
accuracy; in *FLOAT64 mode they have approximately a 15 significant-figure accuracy.
BBC BASIC for Windows doesn't necessarily run any more slowly in *FLOAT64 mode (in
fact, it may run more quickly because it uses the CPU's numeric data processor) but variant
numeric variables and arrays occupy more memory.
BBC BASIC for Windows version 5.95a or earlier only
Variant variables
created in *FLOAT40 mode are independent of variables created in *FLOAT64 mode, and can
co-exist. In the rare circumstance that you need to copy a 40-bit variable into a 64-bit
variable, or vice versa, you can do that only in *FLOAT40 mode by adding a # suffix to the name
of the 64-bit variable. One use for that facility is to read a data file written in a different *FLOAT
mode:
The above program segment reads a 40-bit value from a data file, then copies it into a 64-bit variable.*FLOAT 40 INPUT #file, A A# = A *FLOAT 64 PRINT A#
BBC BASIC for Windows version 5.95a or earlier only
Numeric constants are converted to 40-bit or 64-bit binary floating-point format according to which
*FLOAT mode is currently selected. If you want to force conversion to a 64-bit double, even
when in *FLOAT40 mode, you can do so by adding a # (hash) suffix:
A# = 1.234# B# = PI# PRINT PI#-PI
The required attribute(s) are specified using the letters B, I, U and (for strikeout, when available) Q. The underscore (U) and strikeout (Q) attributes are mutually-exclusive.*FONT Arial,16 *FONT Courier New,20,U *FONT Letter Gothic,12,BI OSCLI "FONT "+fontname$+","+STR$pt%+","+style$
If the *FONT command is mistyped, or if the requested font is not installed, Windows™ will do its best to select a font similar to the one you requested. Unfortunately it doesn't always do this very well, and the result can be the selection of a 'symbols' font. If this happens, what is displayed won't make much sense! You can find out which font has been selected using the GetTextFace Windows API function.
If no typeface, size or style is specified, *FONT selects the System Fixed Font:
Note that the size at which the font is displayed on the screen depends on the current dots per inch (dpi) setting. This is most commonly 96dpi, but may be 120dpi (or another value) if Large Fonts have been selected or when using some high-resolution displays. Ideally you should ensure that your program works satisfactorily with either setting.*FONT
Use the *FONT command with care, as selecting a font other than the default can cause unwanted side-effects. For example, if you select a proportional-spaced font and then use the INPUT statement, the input editing features provided will not work correctly. The <backspace> key will not correctly 'blank' (on the screen) the previous character entered, nor will the <cursor left> and <cursor right> keys have the desired effect. This problem can be circumvented by using the FNpsinput function listed below; this implements most of the features of the INPUT statement but will work correctly with a proportional-spaced font:
The function takes as parameters the column and row numbers (as would be needed by TAB(X,Y)) and a prompt string. It returns the string which was entered by the user.DEF FNpsinput(X%,Y%,prompt$) : LOCAL A$,C%,K% SYS "SetBkMode", @memhdc%, 1 VDU 23,0,18,2,0;0;0;23,0,10;0;0;0; REPEAT : OFF PRINT TAB(X%,Y%) prompt$;A$;" "; PRINT TAB(X%,Y%) prompt$;LEFT$(A$,C%); ON : REPEAT K% = INKEY(1) : UNTIL K%<>-1 CASE K% OF WHEN 8,127: IF C% A$ = LEFT$(A$,C%-1) + MID$(A$,C%+1) : C% -= 1 WHEN 13: WHEN 136: IF C% C% -= 1 WHEN 137: IF C% < LEN(A$) C% += 1 OTHERWISE: A$ = LEFT$(A$,C%) + CHR$K% + MID$(A$,C%+1) : C% += 1 ENDCASE UNTIL K% = 13 PRINT = A$
*FONT [name,size[,style]]
*FX 15,n and *FX21,n flush selected internal buffers as follows:
*FX 15,0 flushes all the internal buffers
*FX 15,1 flushes the currently selected input buffer
*FX 21,0 flushes the keyboard buffer
*FX 21,4 flushes the channel 0 SOUND buffer
*FX 21,5 flushes the channel 1 SOUND buffer
*FX 21,6 flushes the channel 2 SOUND buffer
*FX 21,7 flushes the channel 3 SOUND buffer
*FX num,num
*GSAVE ufsp [num,num,num,num]
A rectangular region of BASIC's output window is copied to the printer (assuming your printer supports bit-mapped graphics). The parameters are as follows:*HARDCOPY x, y, w, h, X, Y, W, H
You can print more than one graphic on the same page by using *HARDCOPY multiple times with different offsets specified. Similarly you can combine graphics and text by using *HARDCOPY in conjunction with the VDU 2 and VDU 3 commands. When the entire contents of the page have been output, send a form-feed character (e.g. VDU 2,1,12,3) to cause it to be printed.
x, y The coordinates, in BBC BASIC graphics units, of the bottom-left corner of the region to be printed. w, h The width and height, in BBC BASIC graphics units, of the region to be printed. X, Y The offset, in millimetres, from the top-left corner of the printable area of the paper to the top-left corner of the printed graphics. W, H The width and height, in millimetres, of the printed graphics.
If you have increased the size of the graphics 'canvas' to be greater than the size of your output window (for example using the technique used in SCROLL.BBC) then you can use *HARDCOPY to print the entire canvas, not just what is visible on the screen.
If you omit the destination parameters (X, Y, W, H) the selected region is automatically scaled and centered to fit the page. If you omit all the parameters, the entire output window is scaled and centered to fit the page.
*HARDCOPY [num,num,num,num[,num,num,num,num]]
This results in the following message (or something like it) being displayed:*HELP
BBC BASIC for Windows 5.91a
*HELP
For example consider the following program:*HEX 32 *HEX 64
In *HEX 32 mode the output is:PRINT ~TRUE PRINT &FFFFFFFF PRINT 2000000000 << 1
FFFFFFFF -1 -294967296In *HEX 64 mode the output is:
FFFFFFFFFFFFFFFF 4.2949673E9 4E9
The number following *INPUT corresponds to the channel number returned by the OPENUP function used to open the required comms port; this will be in the range 1 to 4 (see the Serial I/O section for details). Since this is determined at run-time, you will normally need to use OSCLI to access this command.*INPUT 1 OSCLI "INPUT "+STR$channel%
*INPUT 0 restores normal (keyboard) console input.
The following special values provide improved support for console mode programs:
*INPUT 13 | as *INPUT 1, except that 'non overlapped' I/O is used. |
*INPUT 14 | as *INPUT 2, except that 'non overlapped' I/O is used. |
*INPUT 15 | as *INPUT 3, except that 'non overlapped' I/O is used. |
*INPUT num
*KEY |
*K. |
The 'key number' is from 1 to 24 as follows:*KEY 2 "This is key 2" OSCLI "KEY "+STR$keynum%+" """+keystr$+""""
No Key No Key 1 f1 12 2 f2 13 3 f3 14 4 f4 15 5 f5 16 Ctrl/ (or mouse wheel down)
6 f6 17 Ctrl/ (or mouse wheel up)
7 f7 18 Home 8 f8 19 End 9 f9 20 PgUp 10 f10 21 PgDn 11 Shift/Tab (or f11) 22 Ins 24 Backspace 23 Del
The string may contain the 'escape' symbol '|' in order to include non-printing characters. For example, |M indicates CR (carriage-return), |? indicates DEL, || indicates the escape character itself and |! causes bit 7 of the following character to be set. If the string is enclosed in quotes (which is optional), |" allows the character " to be included in the string.
If there is insufficient room for the string, a 'Bad string' error will occur and the key will be loaded with as much of the string as would fit.
*KEY num without a string will empty the specified key and return it to its normal code (see GET).
Compatibility with some BBC Micro programs can be improved by redefining the Backspace key to return the code 127 (DEL) rather than 8 (BS). That can be achieved as follows:
*KEY 24 |?
*KEY num [str]
*LIST |
*LI. |
Note that no indentation or syntax colouring takes place.*LIST progfile OSCLI "LIST "+progfile$
You can use this command to display the contents of a program file saved in BBC BASIC (.BBC) format. You can pause the display either by holding down <Shift> and <Ctrl> simultaneously, or by first entering 'paged' mode by typing Ctrl/N (VDU 14). In 'paged' mode, the display pauses until <Shift> is pressed. To cancel 'paged' mode press Ctrl/O ( VDU 15).
To display a program saved in ASCII text (.BAS) format use *TYPE.
*LIST ufsp
*LOAD |
*L. |
The load address must be given as a hexadecimal number. You must ensure that the specified address is valid and that there is sufficient room for the file to be loaded there. Generally, the address should have been allocated using the DIM statement. If you fail to take these precautions it is very likely that *LOAD will crash BBC BASIC for Windows!.OSCLI "LOAD A:WOMBAT "+STR$~A% OSCLI "LOAD """+file$+""" "+STR$~address%
You can optionally specify the maximum number of bytes to be loaded (prefixed by a + sign) or, equivalently, the first address not to be loaded. The value must be specified as a hexadecimal number:
You must specify the maximum size when loading into an area of memory allocated by DIM LOCAL or a Windows™ API function.OSCLI "LOAD """+file$+""" "+STR$~addr%+" +"+STR$~max% OSCLI "LOAD """+file$+""" "+STR$~addr%+" "+STR$~(addr%+max%)
*LOAD ufsp hexaddr *LOAD ufsp hexaddr +hexsize *LOAD ufsp hexaddr hextop
Once a file has been made read-only, any attempt to write to it will result in the Access denied error.*LOCK WOMBAT.DAT OSCLI "LOCK """+file$+""""
*LOCK ufsp
This affects the recognition of keywords by EVAL. For example if *LOWERCASE ON has been executed, EVAL("pi") will return the value of PI. Otherwise it would result in a No such variable error.*LOWERCASE ON
A word will only be recognised as a keyword if it is entirely capitals or entirely lower-case. A word consisting of a mixture of capitals and lower-case characters will never be mistaken for a keyword.
*LOWERCASE ON also allows lower-case hexadecimal numbers to be accepted (for example &abcd) and the use of a lower-case "e" in numbers entered in 'exponent' format (e.g. 1.2e-3).
To disable the acceptance of lower-case keywords etc. use *LOWERCASE OFF.
When entering statements or commands in Immediate mode the acceptance of lower-case keywords etc. is controlled by the Lowercase keywords item in the Options menu.
*LOWERCASE [ON|OFF]
This sets the printer page margins to the specified values in millimetres. BASIC will not print closer to the edge of the paper than these values. Initially all four margins are set to 10 mm, but note that both the *PRINTER and *PRINTERFONT commands reset the margins to zero, not to 10 mm.*MARGINS left,bottom,right,top
*MARGINS num,num,num,num
If a directory with that name already exists, the File exists error will result.*MD D:DATA *MKDIR \BBCBASIC\TRIALS OSCLI "MKDIR """+directory$+""""
*MD [d:][\]path *MKDIR [d:][\]path
The specified position (x,y) corresponds to the bottom-left corner of the image, and is given in BBC BASIC for Windows graphics units. The size and shape of the image may optionally be specified, in which case the image is scaled as necessary; this may result in a loss of quality. If the width and height are omitted the image is displayed without scaling.OSCLI "MDISPLAY "+STR$~addr OSCLI "MDISPLAY "+STR$~addr+" x,y" OSCLI "MDISPLAY "+STR$~addr+" x,y,w,h"
BBC BASIC for Windows version 6.10a or later only
An additional parameter may be specified, corresponding to a hexadecimal value
that will be interpreted as a 'transparent' or 'key' colour; any pixels with this colour
in the image will not be plotted and whatever was 'behind' will show through (requires
Windows 2000 or later):
The key colour must be specified in whatever format the bitmap data uses internally, so if it's a 24 bits-per-pixel bitmap specify a six-digit hexadecimal value in the format rrggbb (if the key colour is black specify it as 1000000). If the bitmap has a different pixel format specify it in whatever representation the bitmap uses. In the special case of a 16 bits-per-pixel bitmap ensure that you choose a key colour which has low RGB values, for example R=1, G=1, B=1 which corresponds to the hexadecimal value 0421 in a RGB555 bitmap.OSCLI "MDISPLAY "+STR$~addr+" x,y,w,h,k"
The quality of the displayed image will be affected by your current display settings (right-click on the desktop, select Properties then Settings). For best results ensure you are using High Colour (16-bit) or True Colour (24-bit), but see the Compatibility limitations section for notes on the effects of the different settings.
The position and size values must be integers; if necessary use the INT function to ensure there is no decimal point.
When the image is scaled, you may find that the quality is improved by preceding the *MDISPLAY command with the following statement:
SYS "SetStretchBltMode", @memhdc%, 3
*MDISPLAY is useful if you want to display the same image many times, since using *DISPLAY involves an overhead of reading the file each time. With *MDISPLAY you can load the file once (using *LOAD) and then display it many times. See also *SCREENSAVE.
*MDISPLAY hexaddr [num,num[,num,num[,hex]]]
*NOEGA
The number following *OUTPUT corresponds to the channel number returned by the OPENUP function used to open the required comms port; this will be in the range 1 to 4 (see the Serial I/O section for details). Since this is determined at run-time, you will normally need to use OSCLI to access this command.*OUTPUT 2 OSCLI "OUTPUT "+STR$channel%
*OUTPUT 0 restores normal (screen) console output.
The following special values provide improved support for console mode programs and for emulating the LPRINT statement available in some BASIC dialects:
*OUTPUT 13 | as *OUTPUT 1, except that 'non overlapped' I/O is used. |
*OUTPUT 14 | as *OUTPUT 2, except that 'non overlapped' I/O is used. |
*OUTPUT 15 | output is redirected to the printer. |
Outputting text in *OUTPUT 15 mode has the side-effect of doing a VDU 3,6.
*OUTPUT num
Once a MIDI file is playing you cannot issue another *PLAY command until it has stopped (doing so will result in the Device unavailable error). However, you can cancel the current MIDI file using SOUND OFF.*PLAY midifile OSCLI "PLAY """+midifile$+""""
You can discover whether a MIDI file is playing by using the @midi% System variable; this will be non-zero if a MIDI file is playing.
If the filename extension is omitted, .MID is assumed.
If you have a SoundBlaster™-compatible sound card, you can control the playback volume as follows:
where volume% is in the range 0 (minimum) to 65535 (maximum). Note that the volume change will affect all subsequent MIDI audio output.SYS "auxSetVolume", 1, volume% + (volume% << 16)
*PLAY ufsp
The printer name is case insensitive, but otherwise must be precise. If the specified printer does not exist the No such printer error will result.*PRINTER HP Laserjet Plus OSCLI "PRINTER "+printer$
Changing the printer initialises the page margins to zero, not to the default value of 10 millimetres. You should normally follow the *PRINTER command with a *MARGINS command to set the page margins appropriately.
An alternative way of changing the printer is to present the user with the Print Setup dialogue box which will allow him not only to select the printer but also the printer options (e.g. print quality), page orientation and paper size.
*PRINTER name
If the *PRINTERFONT command is mistyped, or if the requested font is not installed, Windows™ will do its best to select a font similar to the one you requested. Unfortunately it doesn't always do this very well, and the result can be the selection of a 'symbols' font. If this happens, what is printed won't make much sense!*PRINTERFONT Arial,16 *PRINTERFONT Courier New,20,U *PRINTERFONT Letter Gothic,12,BI
Changing the printer font initialises the page margins to zero. You may need to follow the *PRINTERFONT command with a *MARGINS command to reset the page margins appropriately.
*PRINTERFONT name,size[,style]
*QUIT
For example if displaying an animated graphic you may need to force the display to update immediately, otherwise one or more frames of the animation may never be seen. Alternatively you may want to delay the refresh until an entire frame has been drawn, to reduce flicker. The options are as follows:
*REFRESH forces an immediate screen refresh. *REFRESH OFF disables the automatic refresh; the screen will only be updated as the result of a *REFRESH command. *REFRESH ON restores the normal behaviour.
*REFRESH [ON|OFF]
If a file already exists with the new name, a File exists error will occur.*REN OLDFILE NEWFILE OSCLI "REN """+oldname$+""" """+newname$+""""
If the summed lengths of the old and new filenames exceeds 254 characters a String too long error will result. In that case you can use the Windows™ API instead (the extensions must be included explicitly):
SYS "MoveFile", oldname$, newname$
*REN ufsp ufsp *RENAME ufsp ufsp
You can only remove an empty directory. If the directory contains any files you will get an 'Access denied' error. If the directory doesn't exist, you will get a File or path not found error.*RD D:DATA *RMDIR \BBCBASIC\TRIALS OSCLI "RMDIR """+directory$+""""
*RD [d:][\]path *RMDIR [d:][\]path
*RUN |
*/ |
BBC BASIC for Windows will wait until the command completes, but if you press <Escape> the waiting will be aborted. If you terminate the command string with a semicolon (;) then BASIC will not wait for the command to complete.
See also the ShellExecute Windows API function.*RUN C:\Program Files\Microsoft Office\Office\Winword OSCLI "RUN " + command$
*RUN command [;]
*SAVE |
*S. |
You must specify the start address and either the length of the area of memory (preceded by a +) or the first address not to save. There is no 'load address' or 'execute address'.OSCLI "SAVE PROGFILE "+STR$~PAGE+" "+STR$~TOP OSCLI "SAVE """+file$+""" "+STR$~start%+" +"+STR$~length%
*SAVE ufsp aaaaaaaa +llllllll *SAVE ufsp aaaaaaaa bbbbbbbb
If no position or size is specified, the entire window is saved (so long as the graphics ORIGIN hasn't been changed). Otherwise the rectangle whose bottom-left corner is at xpos,ypos and whose size is width (horizontal) by height (vertical) is saved. The position and size are given in BASIC's graphics units.*SCREENSAVE screen.bmp xpos,ypos,width,height OSCLI "SCREENSAVE """+file$+""" "+STR$xpos%+","+STR$ypos%+","+STR$width%+","+STR$height%
You can, of course, copy BASIC's output window to the clipboard using Alt-PrintScreen.
To display an image saved with *SCREENSAVE see *DISPLAY and *MDISPLAY.
*SCREENSAVE ufsp [num,num,num,num]
See also *EXEC and *SPOOLON.*SPOOL LISTING.TXT OSCLI "SPOOL """+file$+"""" *SPOOL
*SPOOL [ufsp]
You can use this command to add text to the end of a previously used spool file.*SPOOLON LISTING.TXT OSCLI "SPOOLON """+file$+""""
*SPOOLON ufsp
you can additionally intercept the WM_NOTIFY, WM_DROPFILES, WM_MENUSELECT, WM_INITMENU, WM_INITMENUPOPUP, WM_HOTKEY, WM_HELP and WM_CONTEXTMENU messages; refer to Microsoft documentation for details of these messages.*SYS 1
The ON SYS handler must test the value of the @msg% system variable to determine which message was received, as follows:
*SYS is equivalent to *SYS 0; it restores the default condition of intercepting only WM_COMMAND.
Message @msg% WM_NOTIFY 78 WM_HELP 83 WM_CONTEXTMENU 123 WM_COMMAND 273 WM_INITMENU 278 WM_INITMENUPOPUP 279 WM_MENUSELECT 287 WM_DROPFILES 563 WM_HOTKEY 786
The @wparam% value of the WM_NOTIFY message contains the control's ID in the LS 16-bits (LOWORD) and the notification code in the MS 16-bits (HIWORD). This makes it possible to determine the notification code even when the parameter block pointed to by @lparam% is no longer valid.
The @wparam% value of the WM_HELP message contains the context type in the LS 16-bits (LOWORD) and the control's ID in the MS 16-bits (HIWORD). This makes it possible to determine the control's ID even when the parameter block pointed to by @lparam% is no longer valid.
*SYS [num]
You can select a short unit, for example one centisecond, if you want finer control over the duration of sounds. This may be important if you are using SOUND for purposes other than music, for example to generate morse code. Selecting a shorter unit also reduces the latency (the time between executing the SOUND statement and the sound actually being produced). However it places greater demands on your PC and on some systems may cause the sound output to 'stutter'.
Note that the maximum duration of a single SOUND statement is 254 times the selected unit.
By adding 128 to the *TEMPO value you can configure SOUND channel 0 to be a 'tone' channel rather than a 'noise' channel; this makes it possible to generate 'four voice' music:*TEMPO 4
*TEMPO 132
*TEMPO num
Note that the timer period determines the flash rate of flashing characters in MODE 7. You are recommended not to change it when using that mode. The default periodicity (if no *TIMER command is issued) is 250 milliseconds (4 Hz).*TIMER 200
*TIMER num
*TV
*TYPE |
*T. |
You can use this command to display the contents of an ASCII file. You can pause the display either by holding down <Shift> and <Ctrl> simultaneously, or by first entering 'paged' mode by typing Ctrl/N (VDU 14). In 'paged' mode, the display pauses until <Shift> is pressed. To cancel 'paged' mode press Ctrl/O ( VDU 15).*TYPE modes.txt OSCLI "TYPE """+file$+""""
To display a program saved in internal (tokenised) format use *LIST.
*TYPE ufsp
This command reverses the effect of *LOCK.*UNLOCK ADDRESS.DTA OSCLI "UNLOCK """+file$+""""
*UNLOCK ufsp
*| any text
A%=&87 char=(USR(&FFF4) AND &FF00) DIV 256
The ASCII value is loaded into byte zero of the 9 byte table called 'pattern' and the pattern is returned in the 8 bytes 'pattern?1' to 'pattern?8. As with the BBC Micro, the address of the table 'pattern' is passed in X% and Y%. The least significant byte is passed in X% and the most significant in Y%DIM pattern 8 ?pattern=character A%=&0A X%=pattern MOD 256:Y%=pattern DIV 256 CALL &FFF1
Note that the pattern is read from a built-in font which resembles that of the BBC Micro. It does not correspond to the actual font which is used when text is written to the screen by BASIC. Generally speaking the fonts used by Windows™ do not correspond to an 8 x 8 pixel pattern.
You can, if you wish, use this built-in font in a BASIC program (instead of a standard Windows™ font) by replacing all the standard characters with user-defined characters using VDU 23 as follows:
DIM p 8 A% = &0A X% = p MOD 256 Y% = p DIV 256 FOR N% = 32 TO 127 ?p = N% CALL &FFF1 VDU 23,N%,p?1,p?2,p?3,p?4,p?5,p?6,p?7,p?8 NEXT
All strings are CR-terminated. In the case of 'oskey' the carry flag is cleared if no key was pressed within the timeout period. In the case of 'osbget' the carry flag is cleared if at end-of-file. In BBC BASIC for Windows version 6 or later only the EDX register contains the most significant 32-bits of the file pointer/length.CALL "osbget" ; Read byte from file to AL, EBX contains channel number CALL "osbput" ; Write byte from AL to file, EBX contains channel number CALL "osrdch" ; Read keyboard character to AL CALL "osasci" ; Write AL to the VDU drivers (plus LF if CR) CALL "osnewl" ; Write LF,CR CALL "oswrch" ; Write AL to the VDU drivers CALL "osword" ; Read character dot pattern, EDX addresses buffer CALL "osbyte" ; Read character at cursor position to AL CALL "oscli" ; Various OS commands, EDX addresses string CALL "osline" ; Read a line from the console, EDX addresses buffer (DL=0) CALL "osshut" ; Close a file, EBX = channel number CALL "getptr" ; Read file pointer, EBX = channel number, result in EDX:EAX CALL "setptr" ; Set file pointer, EBX = channel number, EDX:EAX = value CALL "getext" ; Read file length, EBX = channel number, result in EDX:EAX CALL "setext" ; Set file length, EBX = channel number, EDX:EAX = value CALL "osopen" ; Open a file, EDX addresses filename, AL = 0 (read) ; 1 (create) or 2 (update), channel number returned in EAX
|
CONTINUE
|