EuSQLite

new topic     » topic index » view thread      » older message » newer message

Hi Chris,

out of curiosity, I just downloaded your file "eusqlite.zip".
At the first glance, I stumbled across the function peek_sequence().
Below there are some other functions which might be faster.
I don't know whether that really matter, though.

Regards,
   Juergen

------------------------------------------------------------------------

global function peek_sequence (atom addr, integer len)
   integer i, tmp
   sequence seq

   seq=""
   i=0
   tmp=peek(addr)
   while (tmp != 0 and i<len) do
      seq = append(seq, tmp)
      i = i + 1
      tmp = peek(addr+i)
   end while

   return seq
end function

--======================================================================

global function peek_sequence1 (atom addr, integer len)
   integer i, tmp
   sequence seq

   seq = repeat(0, len)
   i = 0
   tmp = peek(addr)
   while tmp != 0 and i < len do
      i += 1
      seq[i] = tmp
      tmp = peek(addr+i)
   end while

   return seq[1..i]
end function

------------------------------------------------------------------------

global function peek_sequence2 (atom addr, integer len)
   integer i
   sequence seq

   seq = peek({addr, len})
   i = find(0, seq) - 1
   if i = -1 then
      i = len
   end if

   return seq[1..i]
end function

------------------------------------------------------------------------

atom Kernel32
integer Lstrlen

if platform() = WIN32 then
   Kernel32 = open_dll("kernel32.dll")
   Lstrlen  = define_c_func(Kernel32, "lstrlenA", {C_POINTER}, C_ULONG)
end if

global function peek_sequence3 (atom addr, integer len)
   integer i

   i = c_func(Lstrlen, {addr})
   if i > len then
      i = len
   end if

   return peek({addr, len})
end function

------------------------------------------------------------------------

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu