?ILLEGAL QUANTITY ERROR
Apple Apple II
Severity: MinorWhat Does This Error Mean?
?ILLEGAL QUANTITY ERROR means you passed a number outside the valid range to a BASIC command or function. For example, POKE with an address above 65535, or COLOR= with a value above 15. Check that your numeric arguments are within the expected range.
Affected Models
- Apple II
- Apple II Plus
- Apple IIe
- Apple IIc
- Apple IIGS
- AppleWin emulator
Common Causes
- POKE address below 0 or above 65535
- POKE value below 0 or above 255
- COLOR= value above 15 (lo-res) or HCOLOR= above 7 (hi-res)
- CHR$() with a value below 0 or above 255
- HTAB or VTAB with a value outside the screen dimensions
How to Fix It
-
Check the value you are passing to the command.
POKE requires an address from 0 to 65535 and a value from 0 to 255. COLOR= accepts 0 to 15 for lo-res graphics. HCOLOR= accepts 0 to 7 for hi-res graphics.
-
Add a bounds check before the command.
Before POKE A, V add: IF A < 0 OR A > 65535 THEN PRINT "ADDRESS OUT OF RANGE" : GOTO (safe line) This prevents the error and tells you which value caused it.
-
Make sure variables have not overflowed due to calculations.
If a loop increments a variable beyond the expected range, the POKE or COLOR= call at the end will fail. Add a PRINT statement before the failing line to see the actual value.
-
For HTAB and VTAB, stay within screen limits.
HTAB accepts 1 to 40 (or 1 to 80 on an 80-column card). VTAB accepts 1 to 24. Values outside these ranges cause ILLEGAL QUANTITY.
Frequently Asked Questions
What is the valid range for POKE on the Apple II?
POKE takes two arguments: an address (0 to 65535) and a value (0 to 255). POKE 49200, 0 is valid. POKE 70000, 0 causes ILLEGAL QUANTITY because 70000 exceeds 65535.
Why does COLOR= only accept 0 to 15?
The Apple II lo-res graphics mode supports exactly 16 colours, numbered 0 (black) through 15 (white). There is no colour 16 or higher, so any value above 15 is illegal.