BinaryInBin (equivalent for StringInStr)

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(\$-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

Share on other sites

you could do this

```\$binary = ;your binary code
\$string = string(\$binary)
\$g = stringinstr(\$string, \$whatever u want)
;then convert it back to binary
\$rebinary = stringtobinary(\$string)```

`global \$warming = true`

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)```

Create an account

Register a new account

×

• Wiki