Re: Reading UDTs out of a byte array (CopyMemory vs Get on a disk file)

From: J French (erewhon_at_nowhere.com)
Date: 06/20/04


Date: Sun, 20 Jun 2004 09:07:42 +0000 (UTC)

On Sat, 19 Jun 2004 23:04:31 GMT, "Beowulf"
<beowulf_is_not_here@hotmail.com> wrote:

<snip>

>>
>> It is a cheat, and slightly naff, but you are currently at risk of
>> complicating a comparatively simple routine
>> ie: the 'means' is dominating the 'end'
>
>This was my original fall back plan. I like the idea of doing all
>my work in memory and thought it'd be a cool concept. Plus I
>was looking forward to getting some experience with a some new
>tools and algorithms. I think I'm probably going to with the naff
>solution. The only real difficulty in that instance is determining
>a) when to do a local copy + read and b) where to copy the file to.

Compare FileDateTimes between the NW version and the local one

To be honest, it probably takes as long to get the FileDateTime as to
read the entire file, my guess is that your network is slow at
responding to all requests regardless of the amount of data
transferred in each request
- that is borne out by your being able to grab the file in 1 sec.

Also you might as well use FileCopy

The API GetTempPath is probably the best location for the file

>I'm thinking that I'll just add a write-only property to the main
>object and if it's non-blank I copy the file to that temp file and
>read from it. The upside (and downside) to this method is that
>the client app gets all the control over whether local caching is
>done. It makes the object more flexible, but it also breaks
>encapsulation.

I dont think it breaks encapsulation
- as far as your routine is concerned it is reading the data from the
NW file

>If anyone has any more thoughts, I'm probably
>going to play around with trying to read out what I need from
>the byte array for 2 more days. I'll appreciate any other comments.

If you really want to fill the UDT with directly from the Byte Array
then I would strongly suggest that you fill the individual fields

   eg: UDT.Int = ReadInt( B() )
          UDT.Str = ReadStr( 10, B() )

At least you will be able to see what is going on in your own code.



Relevant Pages