comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Locating sequence of bytes within binary file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Locating sequence of bytes within binary file [message #71393 is a reply to message #71334] Thu, 17 June 2010 01:03 Go to previous messageGo to previous message
medd is currently offline  medd
Messages: 8
Registered: June 2010
Junior Member
On Jun 16, 7:46 pm, pp <pp.pente...@gmail.com> wrote:
> It is not the prettiest solution, but you could turn your byte array
> into an array of strings of the byte values. That is, a print-like
> conversion, instead of byte to string conversion. Something like
>
> scontent=strjoin(string(int(fcontent),format='(I3.3)')))
>
> Then search for a similarly stringified version of your byte pattern
>
> spattern=strjoin(string(int(sequence_searched),format='(I3.3 )')))
>
> if stregex(scontent,spattern,/boolean) then ...
>
> I did not test it, but I think it should work, at the cost of using 3
> bytes for each byte in the original content (3 ASCII digits for each
> value). This also avoids the other problem with your initial solution,
> which would happen if the string from your byte pattern happened to
> have any special characters, which would be interpreted non-literally
> in a regex.

Thanks for all replies.

I find pp's solution to be really funny, you got it :) And still it
works, without using external libraries and being reliable. I go for
that!

But I have to admit that I am a bit sad to learn that such a problem
is so difficult to tackle (in this case regarding memory usage).

I am not an expert, but when I explain IDL to newbies I always say
that it is a "matrix-oriented language", with all possible operations
you can imagine on arrays. But looking for more than one consecutive
value within an array seems to be too hard...

Could it be a suggestion for an addition in later versions? Hopefully
IDL8 is out really soon ! (even without this feature)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: pixel information using envi+idl
Next Topic: WINDOW: Routine is not defined for current graphics device.

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 13:36:46 PDT 2025

Total time taken to generate the page: 0.24496 seconds