Hello Charles
In PB they have a PEEK$ statement, what is the equivalent in O2 ?
some people said that PEEK$ work could be done using the Mid() statement
Very easy to write your own, if you know how to work with pointers.
I have plainty of C++ code to emulate the PB string management, most of them are written for 64-bit UNICODE (Windows native).
They could be found in the Tools.h include file, that comes along in all my C++ projects.
The MoveMemory {RtlMoveMemory} API is also the lowest way to manipulate anything. And it works with any language.
Yes, copying with pointers is a fundamental ability. In o2, peek$ would require 2 steps
1 make a null string to receive the bytes
2 copy the bytes
copy dest, source, count
You can also copy to and from other variable types, such as ints, floats and UDTs. The compiler won't try to prevent you :)
'2018-05-02 T 12:11:03
'peek$
string s="0123456789"
string r=nuls 8
copy strptr(r),strptr(s)+1,8
print r
'
'peek int
string s="0123456789"
int v[2]
copy @v,strptr(s)+1,8
print hex(v[1]) ", " hex(v[2])
Thanxx Charles and Patrice
as for the Peek$ , for the string s="0123456789"
then
string r=nuls 8
should have been
string r=nuls 9
bcos the string length is 9
am i correct?
While for the peek int , it should be
copy @v,strptr(s)+1,9
instead of
copy @v,strptr(s)+1,8
The demo was to peek at the middle 8 characters (ignoring 0 and 9).