Contents / Reference section / BASIC keywords / Previous letter / Next letter / Index
To copy part of one string into another string. For example if
demo$="DOGMATIC"
then the middle part of demo$, starting at position 4 and going on for 3 letters i.e.
MID$(demo$,4,3)
would equal MAT. In fact MID$ can be used to copy any part of a string - not just the middle part. Thus
MID$(demo$,1,3) would equal DOG and
MID$(demo$,5,4) would be ATIC
This string-function is very useful for selecting one word out of a long line. There is a demonstration program on page 266 under the keyword GOSUB and another under the keyword LEN on page 285.
If the last number is omitted then the function returns with the rest of the string.
RESTofLINE$=MID$(main$,10)
A string function which returns a subsection of the first argument's string. The second argument gives the starting position and the third argument gives the number of characters to be copied. If the source string is too short then the function returns as many characters as possible forwards from the starting position.
<string var>=MID$(<string>, <numeric>[, <numeric>])
LEFT$, RIGHT$, LEN, INSTR$
The function MOD gives the remainder after division. When doing division with whole numbers (I emphasise - with whole numbers) it is sometimes useful to know the remainder. For example 14 divided by 5 leaves a remainder of 4(14=2*5+4). Similarly
PRINT 14 MOD 5
would print 4. The whole number part of the above division is given by the function DIV. Thus
PRINT 14 DIV 5
would print 2.
Notice that the result of both DIV and MOD is always a whole number.
In fact all numbers used in the calculation of the function are first converted to integers (using internal truncation) before the computer calculates the result. Thus
14 DIV 5=2
14.6 DIV 5.1=2
14 MOD 5=4
14.6 MOD 5.1=4
The second example (14.6 DIV 5.1) is really the same as the first. However.
14.6 DIV 4.9=3
and
14.6 MOD 4.9=2
are quite different. In effect the computer sees them as
14 DIV 4=3
14 MOD 4=2
100 LET X=A MOD B
PRINT length MOD 12
A binary operation giving the signed remainder of an integer division. MOD is defined such that
A MOD B = A-((A DIV B)*B)
<num-var>=<numeric> MOD <numeric>
DIV
This statement is used to select which display mode the computer is about to use. On the Model A computer display
modes 4, 5, 6 and 7 may be selected. On the Model B all display modes are available. Changing modes clears the screen.
Mode Graphics Colours Text 0 640x256 2 colour display 80x32 text 1 320x256 4 colour display 40x32 text 2 160x256 16 colour display 20x32 text 3 2 colour text only 80x25 text 4 320x256 2 colour display 40x32 text 5 160x256 4 colour display 20x32 text 6 2 colour text only 40x25 text 7 Teletext display 40x25 text
MODE 7 uses the Teletext standard display characters. These cannot be changed by the user. Since these characters differ slightly from the standard ASCII set you will find that a number of characters on the screen do not correspond to those printed on the keys. For example a left hand square bracket will be displayed as an arrow.
In modes 0 to 6 the character set can be changed by the user.
See VDU 23 on page 384.
You cannot change MODE inside a procedure or function.
10 MODE 5
MODE 7
A statement used to select the display mode which may not be used in a procedure or function. MODE resets the value of HIMEM.
MODE <numeric>
CLS, CLG, HIMEM
This statement moves the graphics cursor to a particular absolute position without drawing a line. For example to move to a point 100 points across the screen and 300 points up the screen one would say
MOVE 100,300
1050 MOVE 100,300
MOVE X,Y
To move the graphics cursor to a new position without drawing a line. This statement is identical to PLOT4.
MOVE <numeric>,<numeric>
DRAW, MODE, GCOL, PLOT