in BASIC ROM:
|List of all BASIC keywords|
Typ: Integer-Function General Programming-Syntax: PEEK(<Memory address>)
The BASIC function PEEK returns the memory contents of the specified address, which must be in the range 0 through 65535. The byte value returned will be in the range from 0 thru 255. If the address given exceeds the limits of the memory map, the BASIC error message ?ILLEGAL QUANTITY ERROR IN line will occur.
POKE 53280, PEEK(53281)
This sets the screen frame to the same color as the background, by reading the value of the latter and POKEing it into the former.
A = PEEK(53281)
Value of background color is transferred in floating point variable A.
Display the code for the current color of the cursor in the ranges from 0 until 15.
PRINT PEEK(53281) AND 15
Display the actual color code (in the range 0 thru 15) of the screen background. The AND operator "masks out" bits in the register not relevant to the color code; causing only "valid" to be reported.
10 A = PEEK(197): IF A=64 THEN 10 20 PRINT "THE PUSHED KEY HAS GOT THE VALUE: "; A 40 IF A=46 THEN END 30 IF A<>0 THEN 10
This program reports the key code of whichever key on the Keyboard is currently being pressed, or the value 64 if no key is pressed. This example can be stopped using not just the RUN/STOP key as usual, but also by pressing the INST/DEL key (whose keyboard code is 0), by virtue of the Conditional branch in line 30.
B% = PEEK(43) + PEEK(44) * 256
This example shows how to use PEEK to read the "actual" value of a two-byte pointer in the low-byte/high-byte form, in this case the pointer to the beginning of BASIC RAM. The result, 2049 under default conditions, is stored in the integer variable B%.
Also see the BASIC-Command POKE.