what would be the best way to return the contents of a memory area as an hex string?, the fact that pb works always with unsigneds messes me a bit
peekHEX(address,len)
Peek hex string?
Try these procedures:
Code: Select all
Procedure.s PeekHEXByte(*Address)
ProcedureReturn RSet(Hex(PeekB(*Address)), 2, "0")
EndProcedure
Procedure PeekHEXWord(*Address)
ProcedureReturn RSet(Hex(PeekW(*Address)), 4, "0")
EndProcedure
Procedure PeekHEXLong(*Address)
ProcedureReturn RSet(Hex(PeekL(*Address)), 8, "0")
EndProcedure
Procedure.s PeekHEX(*Address, len)
Out.s = ""
For a = 0 To len-1
Out + PeekHEXByte(*Address+a)
Next
ProcedureReturn Out
EndProcedure
P4 2.4GHz, 256 MB, WinXP Pro, onboard video&audio.
The Programmer's Drinking Song:
"99 little bugs in the code,
99 little bugs.
Fix one bug, recompile
100 little bugs in the code."
The Programmer's Drinking Song:
"99 little bugs in the code,
99 little bugs.
Fix one bug, recompile
100 little bugs in the code."
It does not work, at least is not what you would see in an hex editor, you have to convert to unsigned, this worked
Code: Select all
procedure.s peekHEX(mem,bytes)
st$=""
for x=0 to bytes-1
vs.b=peekb(mem+x)
vu.w = vs & $FF
h$=hex(vu)
if len(h$)=1 : h$="0" + h$ : endif
st$=st$ + h$
next
procedurereturn st$
endprocedure