Contents / Reference section / BASIC keywords / Previous letter / Next letter / Index


B

BGET# get a byte from file

Purpose

Numbers and words can be recorded on cassette tape and on floppy discs. The function BGET# enables a single character or number to be read back into the computer from the cassette, disc or network. Before using this statement a file must have been opened using the OPENIN function or else an error will occur (see page 188 for more information about "files"). When a file is opened, using OPENIN, the computer will allocate the file a channel number. This number must be used in all subsequent operations on the file, for example when reading the file or when writing a new file. Again see the chapter on file handling, page 188, for more information.

Examples

6000 character=BGET# (channel)

340 next_letter%=BGET#C

Description

A function which gets a byte from the file whose channel number is the argument. The file must have been opened before this statement is executed.

Syntax

<num-var>=BGET#<num-var>

Associated keywords

OPENIN, OPENOUT, CLOSED, EXT#, PTR#, PRINT#, INPUT#, BPUT#, EOF#

BPUT# put a byte to a file

Purpose

To store a byte on the cassette or disc. See page 188 for a more detailed description of file handling. The number which is sent to the file can have any value between 0 and 255. If you attempt to store a number that is greater then 255 then 256 will be repeatedly subtracted from the number until it is less than 256. The final number will then be sent to file. (This statement is used to store single bytes - not large numbers. Large numbers can be stored using PRINT#.) As with BGET# the file must be "open" before this statement can be used.

Examples

30 BPUT# channel,number

700 BPUT#N,32

450 BPUT# STAFF_FILE,A/256

Description

A statement which puts a byte to the file whose channel number is the first argument. The second argument's least significant byte is sent. The file must be open before this statement is executed.

Syntax

BPUT#<num-var>, <numeric>

Associated keywords

OPENIN, OPENOUT, CLOSE#, EXT#, PTR#, PRINT#, INPUT#, BGET#, EOF#

Exit: BBC Microcomputer User Guide; Kasoft Typesetting; Archer


The BBC Microcomputer User Guide was written by John Coll and edited by David Allen for the British Broadcasting Corporation.

Optical character recognition and original formatting effort by Mark Usher.

HTML version maintained by: Kade "Archer" Hansson; e-mail: archer@dialix.com.au

Last updated: Monday 12th February 2001