Skip to content
Paul Squires edited this page Oct 19, 2026 · 2 revisions

Home › Memory Functions › Poke

Poke

Writes a value to an address, as a byte or as a given type.

Syntax

Declare Sub Poke ( ByVal address As Any Ptr, ByRef value As UByte )
Declare Sub Poke ( datatype, ByVal address As Any Ptr, ByRef value As datatype )

Parameters

  • datatype
  • address
  • value

Description

Poke assigns a value to a location in memory. It is equivalent to

*cast(ubyte ptr, address) = value

or

*cast(datatype ptr, address) = value

When datatype is a user-defined type, Poke assigns value using the type's Operator Let.

Note: When using Poke, the -exx compiler option does not add code for null-pointer checking (no nullity test on the value of address).

Remarks

Usage

Poke [ datatype, ] address, value

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

Examples

Dim i As Integer, p As Integer Ptr

p = @i

Poke Integer, p, 420

Print Peek(Integer, p)

Will produce the output:

420

Category: Memory Functions
Kind: sub


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally