PEEK

BASin

PEEK

Function

PEEK gives the value of the byte stored at a particular location in the memory.

How to use PEEK

PEEK is followed by a numeric value, for example

80 LET x=PEEK(256*y)

Note that an expression must be enclosed in brackets. The value following PEEK is rounded to the nearest integer if necessary, and may range from 0 to 65535 to give an address in the memory. PEEK then returns the value of the byte (a number from 0 to 255) at the address specified.

Example

The number of frames of the display that have occurred since the program was last reset is stored at addresses 23672 to 23674. As the frames are produced at a regular rate, PEEKing these locations gives a method of measuring time. The following line displays the time in seconds since the last reset (less any time spent in producing sounds).

10 PRINT PEEK(23672+256*PEEK 23673+65536*PEEK 23674)/50

Format

  • PEEK int-num-const
  • PEEK int-num-var
  • PEEK (int-num-expr)

See also

Chapter 14, Chapter 18.