From: Michelle on
Peter,

Thanks for the explanation.
As mentioned before, it's not so important but I was only curious.

Regards,

Michelle


From: Michelle on
Peter,

My poor man's solution for searching the header [ 0x07 0x00 0x?? 0x00 0x00
0x00 0x07 0x00 0x?? 0x00 0x00 0x00 0x08 0x00 ]
It performs not bad, but probably a nightmare for a real programmer :-)))

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # #
byte[] rgbPattern = { 0x04, 0x00 };
//[ . . .]
if (FRangesEqual(rgbBlockCur, ibOffset, rgbPattern.Length, rgbPattern))
{
Int64 currOffset = stream.Position;
byte[] HeaderBytes = new Byte[14];
stream.Position = ibBaseOffset + ibOffset;
stream.Read(HeaderBytes, 0, 14);
string strHeaderBytes =
(Regex.Replace(BitConverter.ToString(HeaderBytes), "-", ""));

if (IsValidHeader(strHeaderBytes))
{
//Read record
BinaryReader br = new BinaryReader(stream, Encoding.Default);
int firstValue = br.ReadInt32();
int secVaue = br.ReadInt32();
// . . . etc
}


static bool FRangesEqual(byte[] rgb, Int64 ibStart, Int64 ibLength, byte[]
rgbPattern)
{
// unchanged
}

static bool IsValidHeader(string strDataEntered)
{
return Regex.IsMatch(strDataEntered,
@"07000[1-3]00000007000[1-6]0000000800");
}

// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # #

Regards,

Michelle


From: Michelle on
Any feedback on my code ?

> You can do the former by modifying the code I posted. You'll simply have
> to come up with a way of representing your search string in a way that can
> be translated into calls to the FRangesEqual() method.

Couldn't get that working.

Michelle


From: Peter Duniho on
On Fri, 18 Sep 2009 02:24:18 -0700, Michelle <michelle(a)notvalid.nomail>
wrote:

> Any feedback on my code ?

Sorry...haven't had much time to look at it. A quick skim suggests to me
that it ought to work fine; you're delegating most of the work to reading
straight from the file again, which is an effective way of keeping the
code simple and reducing the change for bugs.

Of course, it's not as efficient, but I think you're aware of that. And
correct and working beats fast any day.

>> You can do the former by modifying the code I posted. You'll simply
>> have
>> to come up with a way of representing your search string in a way that
>> can
>> be translated into calls to the FRangesEqual() method.
>
> Couldn't get that working.

Sorry to hear that. I did offer a description of a specific mechanism you
might use to accomplish that. Hopefully with some more effort, you'll be
able to translate that to code. If having that particular efficiency is
important to you, that is. It might not be.

Pete
From: Michelle on
Peter,

> Sorry...haven't had much time to look at it.

I did not know whether it was clear that I would like your opinion.
Thanks for your response.

> Of course, it's not as efficient, but I think you're aware of that. And
> correct and working beats fast any day.

How can I make it more efficient ?

>>> You can do the former by modifying the code I posted. You'll simply
>>> have to come up with a way of representing your search string in a way
>>> that can be translated into calls to the FRangesEqual() method.
[. . . ]
> Sorry to hear that. I did offer a description of a specific mechanism you
> might use to accomplish that. Hopefully with some more effort, you'll be
> able to translate that to code. If having that particular efficiency is
> important to you, that is. It might not be.

It works without error (so far we've verified) and that's most important.
But efficiency is the second most important.
I do not have enough knowledge and experience with C # to construct your
explanation into code.
If you have time and opportunity to spare, you might want to send an
example. I would at least grateful.
I've learned a lot from studying your earlier example.

(because of my translation from English, the aim sometimes lost :-((( )

Thanks in advance,

Michelle