<!-- PDF page 309 -->

## Table of Contents

**Chapter 1 – Basic Programming Concepts .......... 5**\
Introduction ....................................... 5\
PRINT, LET, programs and line numbers ............. 5\
Variables and Arrays ............................... 6\
Assignments ........................................ 6\
Labels .............................................. 8\
Using LIST, RUN and cursors to edit and run programs  8\
REM, NEW, INPUT and GO TO .......................... 9\
Using STOP, BREAK and CONTINUE .................... 10\
Error trapping ..................................... 13\
**ERROR** *[n]* .......................................... 14

**Chapter 2 – Decisions ............................. 16**\
Making decisions ................................... 16\
Using IF to make decisions ......................... 16\
ELSE ............................................... 17\
Case selection with ON ............................. 19\
Decisions with the ? operator ...................... 19

**Chapter 3 – Looping ............................... 21**\
Using FOR, TO and NEXT ............................. 21\
**STEP** ............................................... 22\
EXIT ............................................... 23\
REPEAT...REPEAT UNTIL loops ........................ 24\
WHILE ............................................... 25\
Error trapping within REPEAT...REPEAT UNTIL loops .. 26

**Chapter 4 – Procedures and Subroutines ............ 27**\
Branching .......................................... 27\
GO SUB and RETURN .................................. 27\
LOCAL keyword ...................................... 28\
PRIVATE and PRIVATE CLEAR .......................... 29\
Procedures (DEFPROC / ENDPROC / PROC) .............. 29\
Passing parameters by reference with REF ........... 32\
Reading parameters with DATA and READ .............. 33\
Trapping errors locally ............................. 33

**Chapter 5 – READ, DATA, RESTORE ................... 35**\
READ, DATA and RESTORE ............................. 35\
**DATA (function) .................................... 36**

**Chapter 6 – Expressions ........................... 37**\
Mathematical operations +, - , \* , /, MOD .......... 37\
Order of mathematical calculations ................. 37\
Bitwise, relational and logical operators .......... 37\
Unary/Bitwise NOT (!) .............................. 38\
Bitwise operators <<, >>, &, |, ↑, ↑| .............. 38\
Expressions ......................................... 39\
Variable names and limitations ..................... 39\
Scientific notation ................................. 40\
Decimal, Binary and Hexadecimal numbers ............ 41\
More about Integer Expressions and Variables ....... 41\
Signed vs Unsigned Integer Expressions ............. 45

**Chapter 7 – Strings ............................... 49**\
Introduction ........................................ 49\
String slicing, using TO ........................... 49\
String multiplication using the \* operator ......... 50\
Transforming a string with trailing modifers ....... 51\
Tokenisation of strings ............................. 51

**Chapter 8 – Functions ............................. 52**\
Order of calculations using functions .............. 52\
String functions .................................... 53\
LEN ................................................. 53\
STR$ ................................................ 53\
IN .................................................. 54\
VAL and VAL$ ........................................ 55\
Numeric functions ................................... 55\
SGN ................................................. 55\
ABS ................................................. 56\
**INT ................................................. 56**\
SQR ................................................. 56\
User defined functions using DEF and FN ............ 56\
NextBASIC functions within integer expressions ..... 58

**Chapter 9 – Mathematical Functions ................ 60**\
↑ and EXP ........................................... 60\
LN .................................................. 61\
PI .................................................. 61\
Trigonometry with SIN, COS, TAN, ASN, ACS and ATN .. 62

**Chapter 10 – Random Numbers ....................... 64**\
RANDOMIZE, RND and % RND ........................... 64

**Chapter 11 – Arrays ................................ 67**\
DIM ................................................. 67\
DIM function ........................................ 70

**Chapter 12 – Conditions ............................ 71**\
AND, OR and NOT ..................................... 71

**Chapter 13 – The Character Set ..................... 74**\
CHR$ and CODE ....................................... 74\
The graphics symbols ................................ 74\
Tokens .............................................. 75\
BIN and USR ......................................... 75\
POKE and PEEK ....................................... 76\
Alternative Character Sets .......................... 79\
Character Graphics Mode ............................ 80

**Chapter 14 – More about PRINT and INPUT ........... 81**\
Coordinate Systems .................................. 81\
Screen Modes and Pixel Coordinates .................. 81\
Changing the size of characters ..................... 82\
Using AT to print to a certain location ............. 82\
Using POINT to print to a certain location .......... 85\
SCREEN$ ............................................. 88\
TAB ................................................. 88\
CLS ................................................. 89\
Scrolling ........................................... 89\
Expanding on INPUT .................................. 90\
LINE input .......................................... 91\
Using Expressions for INPUT ......................... 91\
Using control codes with PRINT ...................... 92\
INKEY$ .............................................. 93\
Using INPUT for game controllers .................... 93

**Chapter 15 – Colours ............................... 95**\
An introduction to colour on the ZX Spectrum Next ... 95\
Basics of computer colour ........................... 95\
Colour organisation and representation .............. 95\
Spatial vs Colour Resolution ........................ 95\
Colour attribute display ............................ 98\
Extended colour attribute display ................... 100\
Palette-based hybrid linear bitmapped colour display  101\
Layer 3 colour storage .............................. 102\
Layer 2 priority colours ............................ 102\
More on the LAYER command ........................... 103\
BORDER, PAPER, INK, BRIGHT and FLASH ................ 105\
BORDER .............................................. 107\
INVERSE and OVER .................................... 107\
Using colour control codes .......................... 107\
ATTR ................................................ 108\
PALETTE ............................................. 108

**Chapter 16 – Graphics .............................. 113**\
PLOT ................................................ 113\
DRAW and CIRCLE ..................................... 114\
POINT, POINT TO ..................................... 116\
Using OVER and INVERSE with graphics commands ...... 117\
Using stippling patterns to generate additional colours 118\
Quick erase and fill using LAYER ERASE .............. 118\
Clipping windows .................................... 118\
Tiling ............................................... 119\
Accessing non-supported graphics modes .............. 120

**Chapter 17 – Time and Motion ........................ 121**\
PAUSE ............................................... 121\
Using POKE and PEEK at the System Variables ......... 122\
TIME (command/function) ............................. 122\
Retrieving information from the RTC ................. 122\
TIME$ ............................................... 123\
INKEY$ .............................................. 125\
Animation: a quick primer ........................... 125\
Mass Storage Frame Playback ......................... 125\
Memory Based Frame Playback ......................... 127\
Animation with the Sprite System .................... 128\
Creating Sprites ..................................... 128\
Putting Sprites on Screen ............................ 130\
Animating Sprites .................................... 132\
Moving Sprites on Screen ............................. 134\
Relative sprites ..................................... 136

