Poke example

Started by Frank Brübach, January 15, 2025, 04:46:28 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Hello..

I am looking for a simple poke example with o2. Peek I have found already , thanks

Charles Pegge

string s="Hallo World"
byte *b
@b=strptr s
print b[2]  'peek  97  'a'
b[2]=101    'poke  101 'e'
print s

Frank Brübach

Thank you but its Not very clear for me.. whats exactly  the difference between peek and poke?

uses console

' direct memory manipulation it is a statement provided
' by the language to write values to specific memory addresse

'---------------------- //
'
' that's code example is correct?
'
 DIM x AS BYTE, addr1 AS BYTE PTR
 'addr1 = STRPTR(x) 'VARPTR(x)
dim as byte addr1 at strptr(x)
 x = 5
 PRINT x '5
' POKE BYTE, addr1, 10 ' original
x=10
dim as byte addr1 at strptr(x)
 PRINT x '10
 '
wait
print "ok"

'---------------------- //
' ok below
string s="Hallo World"
byte *b
@b=strptr s

print b[2]  'peek  97  'a'
b[2]=101    'poke  101 'e'

print s '97
print b[2] '101
wait
' ends


Charles Pegge

peek and poke are used in classic basic which does not support pointer variables. Peek is used for reading, and poke is used for writing at a defined memory location.