Jump to content

BinaryInBin (equivalent for StringInStr)


 Share

Recommended Posts

Is there a quick way of finding a binarystream (in memory) in another one.

* Doing a byte by byte comparison is real slow.

* Isn't there an equivalent for StringInStr like BinaryInBin

Something in Pseudocode like below (only much larger images)

Image A has size @desktopwidth, @desktopheight represented in binarystream x

Image B is smaller 10 * 10 represented in binarystream y

for i = 1 to maxline of b

;BinaryInBin($x,$y) // How to do this????

next i

Ofcourse something like below( pseudocode) could work but is slower than matching a full line at once

function BinaryInBin($a,$;)

for $i=0 to BinaryLen($:D-1

match=true

for $j = 0 to BinaryLen($a)-1

if binarymid($b,$i)<>binarymid($a,$j) then

match=false

exit

endif

next

next

endfunc

Link to comment
Share on other sites

thx

I actually thought that string would break on chr(0) obviously its not

$Bin = binary("Elwin" & CHR(0) & "Wildschut")
consolewrite( $bin)
consolewrite(binarylen($bin) & @crlf)

$str = binarytostring($bin)
consolewrite($str )
consolewrite(stringlen($str) & @crlf)

$iS=stringinstr($str, "Wildschut")
consolewrite("Found at " & $is & @crlf)

$bin = stringtobinary($str)
consolewrite( $bin)
consolewrite(binarylen($bin) & @crlf)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...