Peek
Gets the value of an arbitrary type at an address in memory
Declare Function Peek ( ByVal address As Any Ptr ) ByRef As UByte
Declare Function Peek ( datatype, ByVal address As Any Ptr ) ByRef As datatype
Peek( [ datatype, ] address )
address
This procedure returns a reference to the value in memory given by a memory address, and is equivalent to
will produce the output:
Syntax
Declare Function Peek ( ByVal address As Any Ptr ) ByRef As UByte
Declare Function Peek ( datatype, ByVal address As Any Ptr ) ByRef As datatype
Usage
Peek( [ datatype, ] address )
Parameters
address
The address in memory to get the value from.
datatypeDescription
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)
p = @i
Poke Integer, p, 420
Print Peek(Integer, p)
will produce the output:
420
Differences from QB
- Peek did not support the datatype parameter in QB, and could only return individual bytes.
- Peek returns a reference in FB, so can be used to set the memory contents of the address, like with Operator * (Value Of).
- DEF SEG isn't needed anymore because the address space is 32-bit flat in FreeBASIC.
See also