Re: Add/remove zero index of array



Well, actually the goal of this effort is to speed up my disk I/O while
maintaining file compatibility with earlier versions of the program.

When originally written, I didn't bother writing record 0 to the disk file
because it wasn't needed. It wasn't secret or anything, I just didn't bother
wasting the disk bytes with something I auto-generated in the program each
time anyway. Record 0 is like a template record. Records 1 and up are those
that the user has modified. I was using Random Access I/O and just wrote the
records I needed to save.

Now I want to speed up the I/O by using Binary access with Get/Put and that
niggling little record 0 was getting in the way.

--
Tim Rude

timrude@xxxxxxxxxxxxxxxxxx
(remove NOSPAM. for correct email address)

"Randy Birch" <rgb_removethis@xxxxxxxx> wrote in message
news:uq48HtmRIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
One other alternative, presuming that the goal of this effort is to keep
prying eyes from seeing the values of the 0 member, is to just write the
entire array to disk when overwrite the 0 record with some character. Then
you can blast the mess back in later, and use the 0 member without any
other
footwork around the UTD/array format.

--


Randy
http://vbnet.mvps.org/


"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message
news:u5BRUpmRIHA.4400@xxxxxxxxxxxxxxxxxxxxxxx
Yeah, if I wanted to rewrite a pile of code. ;p

Once the array is read, it is used throughout the program in a number of
ways, and the internally created record 0 becomes an important part of
the
array data at that point. Some of the array data (including record 0)
gets
displayed in a sorted listbox and the array index is stored in the
ItemData
property. So eliminating record 0 from the array just complicates a
bunch
of
existing code that's currently working perfectly.

--
Tim Rude

timrude@xxxxxxxxxxxxxxxxxx
(remove NOSPAM. for correct email address)

"Randy Birch" <rgb_removethis@xxxxxxxx> wrote in message
news:eK85QbmRIHA.4272@xxxxxxxxxxxxxxxxxxxxxxx
I would question the need for the 0 member at all, given - from your
description - that you are only using the data this contains internally
in
the app and never saving to disk. Would not a separate dimmed variable
for
the data you put into the 0 member not work?

--


Randy
http://vbnet.mvps.org/


"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message
news:uooT1NmRIHA.2376@xxxxxxxxxxxxxxxxxxxxxxx
Ralph,

Thanks for your input. I think I've actually got it sorted out now.

I'm using a trick suggested by RB Smissaert to adjust the LBound and
UBound
of my array, and then shifting each record up or down. It works and
it
seems
very fast.

--
Tim Rude

timrude@xxxxxxxxxxxxxxxxxx
(remove NOSPAM. for correct email address)

"Ralph" <nt_consulting64@xxxxxxxxx> wrote in message
news:u4gbTCmRIHA.2268@xxxxxxxxxxxxxxxxxxxxxxx
Comments inline ...

"Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx> wrote in message
news:OXDRFYlRIHA.5288@xxxxxxxxxxxxxxxxxxxxxxx
<snipped>

DB( ) is a single-dimension array of UDT records. The UDT consists
only
of
fixed length strings (i.e. String * 10, etc.). Each UDT record is
322
bytes
long.

'==========
Dim FH as Integer
Dim NumOfRecs as Long
Dim DB() as MyUDT

FH = FreeFile
Open DataFile For Binary Shared As #FH

' if the dummy is the same size as MyUDT
Dim dummy As MyUDT

NumOfRecs = LOF(FH) \ 322

NumOfRecs = NumOfRecs - 1
Get #FH, , dummy

ReDim DB(1 To NumOfRecs - 1)
Get #FH, , DB 'Read entire file into array
Close #FH

ReDim Preserve DB(0 to UBound(DB)) 'This is what I need to do but
VB
won't
do it
'==========
<snipped>

If it is a different size, say 300 bytes, do something like this...
[Warning Air Code!]

Dim dummy As String : dummy = String( 300, " ")
Get #FH, , dummy
Dim NumOfRecs As Long : NumOfRecs = LOF(FH) - 300
NumOfRecs = NumOfRecs / 322
...

-ralph










.



Relevant Pages

  • Re: Need feedback on the A5200 storage array....
    ... they don't have the money for a big Hitachi array or a fast FC array with ... Use RAID5 on that kind of hardware. ... ten years or so) that had internal RAID5 controllers. ... I can't simply yank a disk and read its ...
    (comp.unix.solaris)
  • Re: HP EVA4000 / IBM DS4300 / EMC CX3-20/40
    ... Both EMC and EVA are great arrays and they will serve you well. ... disk array with the virtual raidsets on top. ... So, the system admin, and the DBAs had to create and manage lots of ...
    (comp.arch.storage)
  • Re: RAID 5 corruption, RAID 1 more stable?
    ... corruption to either the RAID array itself or the file system. ... The disk array to suffer so many errors (for example disk errors ... There is nothing the disk array can do if the host is broken and ...
    (comp.arch.storage)
  • Bug+fix: PDC20271 RAID detection fails
    ... My array was not detected by my kernel. ... the PDC RAID superblock, that is located at the start ... of the last track on the disk. ... is a multiple of track size and if not, ...
    (comp.os.linux.hardware)
  • Re: Caching control
    ... |> | invalidate/unmap them in order to discard the data from memory. ... |> writing out to disk. ... | easy to discard as clean disk cache. ... stating that a specific amount of RAM can be used only for I/O ...
    (comp.os.linux.development.system)