Extra Help with Tutorial 001


Here are comments to help you with the exercises in Tutorial 001:
PRINT "How does it do it?"
Any characters enclosed in speech marks will be printed exactly (as a string or sequence of characters)

PRINT 5
Numbers will just be printed

PRINT 5+2
In this case the mathematics is done for you!

PRINT "5+2"

PRINT 6/3

PRINT 10*9

PRINT 10*(3+2)

PRINT 12/(5-3)

Here the maths is done for you! .....(/ stands for division, * for multiplication)
a=55
PRINT a
PRINT a/5

In this example a is known as a variable which you hace declred to be 55 until further notice. Because a is not in speech marks it is evaluated in the second line and its value printed. Similarly if we divide a by 5 the result is 11 and this is printed.
PRINT 10^2
PRINT 10^3

Here ^ raises the number in front to the power of the number after the sign. Ten squared (10*10) is 100 and ten cubed (10*10*10) is 1000
PRINT SQR(16)
PRINT SQR(2)

SQR takes the square root of the number in the brackets
A$="This computer is a smart cookie"
PRINT A$
L=LEN(A$)
PRINT L
PRINT LEFT$(A$,13)
PRINT RIGHT$(A$,14)
PRINT MID$(A$,15,2)

Here A$ is pronounced "A string", it can be printed in the second line, its length in characters including spaces is found by LEN, LEFT$ chops off the specified number of characters from the left of the specified string, and RIGHT$ acts similarly from the right, whilst MID$ starts at the first postion specified( in this case 15) and extracts the next specified number of letters (2 in this case)
MODE 8
Specifies a screen mode - in this case a 16-colour screen mode
COLOUR 129
128 (and higher) specifies the background colour which is printed for each character - try other values.
COLOUR  3
Here foreground colours are specified - try other values
MODE1
Another screen mode with bigger letters
PRINT TIME$
TIME$ is available in BB4W (BBC Basic for Windows) to show the current date and time - useful eh? Thus:
PRINT "Today is ";LEFT$(TIME$,15)
PRINT "The time is ";RIGHT$(TIME$,10)
   

If you want to know more about the BBC BASIC instructions used here:

Just click on the BB4W  "Help" button near the top of the editing window, choose "Help Topics" (or simply press the F1 button on your computer keyboard) . Now click the "Search" tab at top left and e.g. enter PRINT, or MODE or LEFT$ and you will see bags more info, and possibly more than you need or want at present. For example when PRINT is entered many references appear in the list which appears, relating to pages in the HELP system which contain the word PRINT. If we highlight the one saying just PRINT it brings up a comprehensive description of the full behaviour of this "command" which starts as follows:

            PRINT                      ( Abbreviation is P.)
A statement which prints characters to the screen or printer. The printer may be turned on with VDU 2 and turned off with VDU 3 (see the VDU emulation section for details).
The items following PRINT are called the print list. The print list may contain a sequence of string or numeric literals, variables and formatting instructions. The spacing between the items printed will vary depending on the punctuation used. If the print list does not end with a semi-colon, a new-line will be printed after all the items in the print list.

At this stage you might like to experiment with making variations on the instructions given in blue above until you feel that you are getting familiar with the commands and can predict their effects.You could save yourself some typing once you realise that BB4W is happy to accept P. as shorthand for PRINT. You can see these shorthand forms of the BASIC keywords in the BB4W HELP file.

Richard Weston's Home Page