[thelist] array comparison question

Matt Warden mwarden at gmail.com
Fri Mar 11 13:14:53 CST 2005


Brian,

On Fri, 11 Mar 2005 08:01:03 -0500, Brian Delaney
<brian.delaney at mccmh.net> wrote:
> This code sorta works. When you look at the contents of the array the
> records are sperated by many blank spaces.
> My goal is that if the agency id in the sql record set is not in the
> arrayagencies I want to add it.
> Any ides? The sql recordset has valid data without any blank rows.

I am not sure exacty what you are trying to do, from your description,
nor am I sure what the database record looks like (it would help if
you could provide an example record), but I can say from what I can
parse out that I would not do it like this. Redim'ing an array is very
expensive, because it works by allocating new (resized) space in
memory, then copying the old array to this space, then removing the
original. It's not a great idea to do this many many times (e.g. in a
loop). Not only that, but your use of an array is also requiring you
to loop through it many many times for searching purposes.

Here's what I would suggest:
Don't use an array as your data structure. This is what is causing
your problems. I would personally use a delimited string, e.g.
"|1231|2342|7895|2345|". Then your search becomes (pardon my vbscript
rustiness) something like: instr(sIdString, "|"&sIdFromDB&"|"). (Note
that an operation similar to redim'ing occurs in vbscript when you
concatenate strings.)

If that doesn't help, give me an example database record and I'll give
it another shot.

Good luck,

-- 
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list