Re: Add/remove zero index of array
- From: "Tim Rude" <timrude@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 24 Dec 2007 14:35:44 -0600
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 keepother
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
footwork around the UTD/array format.the
--
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
getsarray data at that point. Some of the array data (including record 0)
bunchdisplayed in a sorted listbox and the array index is stored in the
ItemData
property. So eliminating record 0 from the array just complicates a
itof
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
VBonlyseems
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
of
fixed length strings (i.e. String * 10, etc.). Each UDT record isbytes
322
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
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
.
- References:
- Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Ralph
- Re: Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Ralph
- Re: Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Randy Birch
- Re: Add/remove zero index of array
- From: Tim Rude
- Re: Add/remove zero index of array
- From: Randy Birch
- Add/remove zero index of array
- Prev by Date: Re: Add/remove zero index of array
- Next by Date: Re: Add/remove zero index of array
- Previous by thread: Re: Add/remove zero index of array
- Next by thread: Re: Add/remove zero index of array
- Index(es):
Relevant Pages
|