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


R

RAD radian

Purpose

To convert an angle measured in degrees to radians. 1 radian equals approximately 57 degrees.

Examples

1030 X=RAD(Y)

PRINT RAD(45)

Description

A function converting an angular argument given in degrees to radian measure.

Syntax

<num-var>=RAD <numeric>

Associated keywords

DEG

READ

Purpose

To enable numbers or words that are required in a program to be made available every time the program is run. It does this by reading numbers or words into numeric or string variables from DATA statements in the program. Most often the data is read into an array. See the keyword DIM on page 120 for more information on arrays.

See the keyword DATA on page 227 for a more detailed description.

Example

100 READ name$(X),A

Description

A statement which copies the next item from a data-list into the variable or variables which follow the keyword READ. The DATA must contain the correct sequence of string and numeric data for the string and numeric variables to be assigned. In other words numeric data must be supplied if a numeric variable is to be filled.

Syntax

READ<num-var>|<string var>{,<num-var>|<string-var>}

Associated keywords

DATA, RESTORE

Demonstration program

200 INPUT "How many pounds can you afford" ,AFFORD

210 PRINT "You can afford the following cars"

220 FOR X=1 TO 10

230 READ NAME$

240 READ PRICE

250 IF PRICE < AFFORD THEN PRINT NAME$

240 NEXT

250 END

500 REM British Leyland Cars

510 DATA METRO HLE,3695

520 DATA etc etc

REM remark

Purpose

To enable the program writer to put remarks and comments into the program to help him remember what the various parts of the program do. The computer completely ignores anything that appears after a REM.

When you first start writing small programs you can get away with having no REMs, but as your programs grow in complexity you will find it quite essential to have them liberally sprinkled over your program. If you come back to a program six months after you wrote it and find no REMs you will have a real job trying to remember how it worked and why you used that variable name etc. etc. Use lots of REMs - it will save you hours of time in the long run.

Examples

10 REM this revision dated 25-3-82

100 REM

550 REM data for British Leyland cars

Description

This statement allows comments to be inserted in a program.

Syntax

REM <anything>

RENUMBER

Purpose

When you type in a program you give each instruction a line number. As the program develops you quite often have to insert extra lines between other lines. You might well need to insert 25 lines between line number 300 and 310 - difficult!

The RENUMBER command will go through your program and renumber it automatically. It deals successfully with things like GOTO 220 - which might well become GOTO 180 etc. However if your program contains the statement GOTO 100 and there is no line 100 then the RENUMBER command will be unable to deal with the problem. and will say

Failed at line....

If you renumber a program containing an ON GOTO statement which contains a calculated line number, e.g.

ON X GOTO 120,240,2*R,1000,2000

then RENUMBER will deal successfully with references before the calculated line number. However it will not deal with the calculated line number or other line numbers in the same statement - ie 2*R, 1000 and 2000 in the example given.

The command RENUMBER will renumber your program giving the first line the number 10, the second 20 and so on.

The command RENUMBER 200 will give the first line of your program the number 200, the second will become line 210 etc. etc.

The command RENUMBER 200,4 would renumber starting with line 200 and then using 204,208 etc. etc.

RENUMBER is a command: it cannot be used in a program, or as part of a multiple statement line.

Examples

RENUMBER

RENUMBER 100,20

RENUMBER 6000

Description

RENUMBER is a command which renumbers a user's program and will correct most of the cross-references within the program.

Syntax

RENUMBER[<num-const>[,<num-const>]]

REPEAT

Purpose

To make the computer repeat a set of instructions a number of times until some condition is met.

If you jump out of a REPEAT...UNTIL loop with a GOTO statement (which is bad practice) you must jump back in.

A single REPEAT may have more than one UNTIL.

Example

10 REM print stars for 1 second

20 NOW=TIME

30 REPEAT PRINT "*";

40 UNTIL TIME=NOW+100

Description

A statement which is the start of a REPEAT...UNTIL loop.

These loops always execute once and may be nested up to a depth of 20.

Syntax

REPEAT

Associated keywords

UNTIL

REPORT

Purpose

To get the computer to report in words what the last error was.

Example

100 REPORT

Description

REPORT prints the error message appropriate to the last error condition.

Syntax

REPORT

Associated keywords

ERR, ERL, ON ERROR

RESTORE

Purpose

Sometimes it is useful to have several sets of data in one program. For example one might want information on British Leyland cars and on Lotus cars as in the example shown on page 128. The RESTORE statement enables the data-pointer to be moved from one set of data to the other.

The word RESTORE by itself resets the data pointer to the first set of data in the program.

Examples

230 RESTORE

100 RESTORE 6500

RESTORE apointer

Description

This statement can be used at any time to reset the data pointer to any selected line number.

Syntax

RESTORE <numeric>

Associated keywords

READ, DATA

RETURN

Purpose

The word RETURN - not the key marked RETURN - is used in a program at the end of a subroutine to make the computer return to the place in the program which originally 'called' the subroutine. See GOSUB on page 265 for more details.

There may be more than one RETURN statement in a subroutine - but preferably there should be one entry point and one (RETURN) exit point.

You should try very hard to avoid leaving a subroutine with GOTO, you should always exit with RETURN. Why? Well you will soon discover in reasonable sized programs that you can get into an awful tangle and lose track of how a program works if you make the program jump all over the place.

The importance of dividing your programs into clearly defined sections wherever possible, with one entry point and one exit point, cannot be over emphasised.

Examples

200 RETURN

300 IF X>4 THEN RETURN

Description

A statement which causes the program to branch to the statement after the one which contained the GOSUB which called the current subroutine.

Syntax

RETURN

Associated keywords

GOSUB, ON GOSUB

RIGHT$

Purpose

To copy the right hand part of one string into another string. For example if

ABCDE$="HOW ARE YOU" then

RIGHT$(ABCDE$,3) would be "YOU" and

RIGHT$(ABCDE$,7) would be "ARE YOU"

Note that RIGHT$(ABCDE$,100) would be "HOW ARE YOU" since there are only eleven characters in HOW ARE YOU.

Examples

A$=RIGHT$(B$,5)

last$=RIGHT$(last$,X)

Description

A string function returning a specified number of characters from the right hand end of another string.

Syntax

<string-var>=RIGHT$(<string>,<numeric>)

Associated keywords

LEFT$, MID$

RND random

Purpose

To generate, or make, a random number.

What exactly this function does is determined by the number which follows the word RND.

RND by itself generates a random whole number between -2147483648 and 2147483647

RND(-X) returns the value -X and resets the random number generator to a number based on X

RND(0) repeats the last random number given by RND(1)

RND(1) generates a random number between 0 and 0.999999

RND(X) generates a random whole number between (and possibly including) 1 and X

The brackets are compulsory and must immediately follow the word RND with no intervening space.

Examples

PRINT RND(6)

340 largenumber%=RND

950 PRINT RND(1)

Description

A function generating a random number. The range of the number generated depends on the argument (if any).

Syntax

<num-var>=RND[(<numeric>)]

Associated keywords

None

RUN

Purpose

To make the computer obey the statements in the program in its memory.

All variables (except the resident integer numeric variables @% and A% to Z%) are first deleted and then the program is executed.

RUN is a statement and programs may therefore execute themselves.

If you want to start a program without clearing all the variables then you can use the statement

GOTO 100

or GOTO whatever line number you wish to start from, instead of RUN.

Examples

RUN

9000 RUN

Description

RUN is a statement causing the computer to execute the current program.

Syntax

RUN

Associated keywords

NEW, OLD, LIST, CHAIN

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