Due to O2's late expansion of macros, and late Metalanguage processing, the two can work together to produce highly flexible code, that supports many different types.
Using Peeks and Pokes as examples:
'2018-05-03 T 11:26:29
'peeks and pokes
'
macro peeks string(r,v,i,n)
===========================
'r returned string
'v variable being peeked
'i offest from variable's base address
'n number of bytes
r=nuls n
#if typecodeof(v)<=0 'not a variable
' ' '
#elseif typecodeof(v)<0x80 'primitive number
copy strptr(r),@v+i,n '
#elseif typecodeof(v)<0x100 'string
copy strptr(r),strptr(v)+i,n '
#else 'UDTs, Objects etc
copy strptr(r),@v+i,n '
#endif
end macro
'
macro pokes (v,i,p)
===================
'v variable being poked
'i offset from variable's base address
'p string containingg bytes to be poked
'
#if typecodeof(v)<=0 'not a variable
' '
#elseif typecodeof(v)<0x80 'primitive number
copy @v+i,strptr(p),len p '
#elseif typecodeof(v)<0x100 'string
copy strptr(v)+i,strptr(p),len p '
#else 'UDTs, Objects etc
copy @v+i,strptr(p),len p '
#endif
end macro
'
'
'TESTS
======
string p,s
s="0123456789"
p=peeks(s,2,4)+peeks(s,8,2)
print p
pokes(s,2,"-")
print s