Poke - Write a BYTE value to a memory address

Top  Previous  Next

Syntax

 

<nByte> := Poke( <nAddress>, <nByteValue> )

 

Parameters

 

<nAddress>

 

Memory address to write to. The address is a  LONGvalue.

 

<nByteValue>

 

The value to write to the memory byte at <nAddress>. It must be a BYTE value.

 

Return value

 

Always NIL.

 

Description

 

Poke writes a BYTE value directly to a memory address. Your program must have write access to the given memory address.

 

Classification

 

Core

 

Category

 

Pointers and Memory

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

Peek, PeekLong, PokeLong

 

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL address,n,data

 

* Prepare a string

data := "Here we go"

 

* Allocate some memory

address := LockNullString(10)

 

* Transfer the string data to memory

FOR n := 1 TO Len(data)

   Poke(address+n-1,Asc(data[n]))

NEXT n

 

* Check if everything worked fine

? ReadMemory(address,10)

 

RETURN NIL