![](/squares_tiny/publisher/0/0/0/0/0/5/5/0/pcn.jpg)
Personal Computer News
![](/themeForest/images/clock.png)
Published in Personal Computer News #077
Two Amstrad Basic Peculiarities
The Amstrad CPC464 has two unusual features in the Basic interpreter.
The first is the treatmentof hexadecimal numbers as signed &DDDDD to return -8739. This is not only annoying when printing out numbers, but causes errors in calculations and FOR...NEXT loops, although PEEK and POKE are not affected.
To get round this problem you can use:
10 DEFFNhex(h)=-65536*(h<0)
FNhex(h) then returns the corrected decimal value for h for calculations or printing, e.g.:
PRINT FNhex(&DDDD)
56797
The same function returns correct values for binary numbers using the '&X' format.
The second peculiarity is in the PRINT formatting. Whenever an item is to be printed away from the edge of the screen, a spurious carriage return is generated if the item would otherwise overlap the right hand edge. For example, in Mode 1, where a$ is more than 20 characters long, PRINT a$:a$ causes a$ to be printed on two successive lines, instead of the same line with overlap onto the second line.
For most print formatting purposes, where overlap onto a new line is undesirable anyway, this is unimportant (although ZONE, which defines the comma spacing, cannot usefully be set greater than half the screen width), but it is most annoying with LOCATE (the Amstrad's equivalent of PRINT AT): LOCATE 35,10:PRINT"MISTAKE" will (in Mode 1) cause "MISTAKE" to be printed at the beginning of line 11, and this occurs even when the printed string consists of non-printing control characters. This can be avoided by using:
2 DEF FNLOKATE$(x,y) = CHR$(31)+CHR$(x)+CHR$(y)
The above example can then be replaced by:
PRINT FNLOKATE$(35,10)+"MISTAKE"
M. D. Barratt
Bournemouth