-- ************************************************************************
-- Script: BYTEARRAY MIMICRY
-- Version: 0.2
-- Date: 2008-11-30
--
-- simulates ByteArray by overwriting obj.ilk ('ilk' as property), ilk(obj) ('ilk' as function) and string(obj)
--
-- ************************************************************************
property ancestor
property ilk -- for overwriting x.ilk -> #byteArray
on new me, p1, p2
me.ancestor = script("ByteArray").new(p1, p2)
me.ilk = #ByteArray
return me
end
----------------------------------------
-- for overwriting x.ilk() or ilk(x) -> #byteArray
----------------------------------------
on ilk me
return #ByteArray
end
----------------------------------------
-- "<ByteArrayObject length = 0 ByteArray = <Void>> "
-- "<ByteArrayObject length = 12 ByteArray = 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c > "
----------------------------------------
on string me
str = "<ByteArrayObject length = "&me.length&" ByteArray ="
if me.length=0 then
put " <Void>" after str
else
cnt = min(me.length, 10)
repeat with i = 1 to cnt
put " 0x" & me._hex(chartonum(me.pData.char[i]))&"," after str
end repeat
delete the last char of str
end if
put "> " after str
return str
end