Gets the value of an arbitrary type at an address in memory
Syntax
Declare Function Peek ( ByVal address As Any Ptr ) As UByte
Declare Function Peek ( datatype, ByVal address As Any Ptr ) As datatype
Note: Peek returns a reference to the value at the specified address. As of version 0.17b, there is no way to specify returning a reference, although this will change in future versions. At that time, this syntax should be changed to accommodate returning a reference.
Usage
Peek( [ datatype, ] address )
Parameters
address
The address in memory to get the value from.
datatype
The type of value to get.
Description
This procedure returns a reference to the value in memory given by a memory address, and is equivalent to
*cast(ubyte ptr, address)
or
*cast(datatype ptr, address)
Example
Dim i As Integer, p As Integer Ptr
p = @i
Poke Integer, p, 420
Print Peek(Integer, p)
will produce the output:
420
Differences from QB
- Only the byte form were supported in QB.
- DEF SEG isn't needed anymore because the address space is 32-bit flat in FreeBASIC.
See also