[REBOL] Re: External library interface
From: lmecir:mbox:vol:cz at: 3-Jul-2003 10:02
Hi all,
for the ones who want to "play with fire", I wrote the functions described below. They
work e.g. under Rebol/View 1.2.8. Usage:
a: "1234" ; == "1234"
adr: address? a
get-mem? adr ; == #"1"
get-mem? adr + 1 ; == #"2"
get-mem? adr + 2 ; == #"3"
get-mem? adr + 3 ; == #"4"
get-mem? adr + 4 ; == #"^@"
set-mem adr + 1 #"a" ; == #"a"
a ; == "1a34"
address?: function [
{get the address of a string}
s [any-string!]
] [address] [
s: make struct! [s [string!]] reduce [s]
address: make struct! [i [integer!]] none
change third address third s
address/i
]
get-mem?: function [
{get the byte from a memory address}
address [integer!]
] [m] [
address: make struct! [i [integer!]] reduce [address]
m: make struct! [c [struct! [chr [char!]]]] none
change third m third address
m/c/chr
]
set-mem: function [
{set a byte at a specific memory address}
address [integer!]
value [char!]
] [m] [
address: make struct! [i [integer!]] reduce [address]
m: make struct! [c [struct! [chr [char!]]]] none
change third m third address
m/c/chr: value
]
-L