A Invalid argument
Sinclair ZX Spectrum
Severity: MinorWhat Does This Error Mean?
Error A on the ZX Spectrum means you passed an invalid argument to a function or command. The value is the wrong type or outside the accepted range — for example, SQR of a negative number or CHR$ of a value above 255. Check the function's requirements and fix the input value.
Affected Models
- Sinclair ZX Spectrum 48K
- Sinclair ZX Spectrum 128K
- Spectrum+
- Spectrum +2
- Spectrum +3
- ZX Spectrum Next
- Fuse emulator
Common Causes
- SQR (square root) of a negative number
- LN or LOG of zero or a negative number
- CHR$ with a value below 0 or above 255
- PEEK or POKE with an address outside 0-65535
- Colour values outside the valid range (0-7 for INK/PAPER)
How to Fix It
-
Check which function or command caused the error and what value you passed.
The error message includes a line number. Use LIST followed by that number to see the line. Identify which function call has the invalid argument.
-
For SQR: make sure the argument is not negative.
SQR(-1) causes error A because square roots of negative numbers are not supported in Spectrum BASIC. Add a check: IF X >= 0 THEN LET R = SQR(X)
-
For CHR$: make sure the value is between 0 and 255.
CHR$(65) gives the letter A. CHR$(300) causes error A because 300 is outside the valid character code range. Check your variable is within bounds before calling CHR$.
-
For INK, PAPER, BORDER: use values 0 to 7 only.
The Spectrum has 8 colours numbered 0 (black) through 7 (white). INK 8 or PAPER 9 causes error A. INK 8 is only valid as a special transparency value in some contexts.
Frequently Asked Questions
What is the full list of ZX Spectrum error codes?
The Spectrum has error codes 0 through R, each identified by a number or letter. 0 = OK (no error), 1 = NEXT without FOR, 2 = Variable not found, 3 = Subscript wrong, A = Invalid argument, B = Integer out of range, and so on through R = Tape loading error.
Why does the Spectrum use letters for some error codes and numbers for others?
The Spectrum uses codes 0-9 first, then continues with A-R for codes 10 onwards. This is simply a numbering convention — A is error 10, B is error 11, and so on.