Re: 2 Dimensional Array Question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



JW,
Thanks for the reply, and yes your code corrected the problem and gives
me an event count for each server. Your suggestion also makes sense, yes I
know roughly how many servers I will be dealing with (minus any that are
offline or unreachable at the time I run the script). With that in mind I can
size the array to that number or plus 5. I wasn't sure what the consequences
would be of setting the array higher then what I was actually dealing with,
i.e. setting the array to 100 when there might only be 90 servers, etc.
Additionally, the script I'm actually working with is exporting the
data to Excel, creating a tab for each server and populating that with event
log data. My goal is for the last tab (the first tab the user sees when the
worksheet is opened) to be a summary showing one line for each server and how
many of the particular events has occurred. The only way I could think to
keep up with the data and then write this on the last tab was with an array.
Based on your statements about using Excel, could I accomplish the same thing
without the array, either using the same Excel worksheet or opening a second
worksheet for just this data and then import it into the first worksheet at
the end? I'm all for doing things the best way or easiest way so I'm open for
suggestions...
Thanks again for taking the time and providing the 'extra' information
along with the suggested code, thats just more I ended it learning.
Jeff

"mr_unreliable" wrote:

Jeff, this code looks a little suspicious:

arrSummary(X, 0) = strComputer
arrSummary(1, X) = intEventCount
X = X + 1
ReDim Preserve arrSummary(1, X)

I would have thought this:

arrSummary(0, X) = strComputer
arrSummary(1, X) = intEventCount
X = X + 1
ReDim Preserve arrSummary(1, X)

Aside from that, I personally prefer to dimension the
array up front. You know about how many computers you
are dealing with. Start with, say:

ReDim arrSummary(1, 100)

The reason I say this is that when you "ReDim" something
then vbs has to go through an orgy of memory management
to save the existing array, re-allocate space (from "the
process heap") and then put your stuff back in the enlarged
array. I have also seen this done in "blocks", for example
adding 10 elements at a time, rather than one-at-a-time.
I think you best bet is to start with a safe number, and if
your client population grows unexpectedly, then just include
some code to (ReDim) allocate more space.

If you look through the ng archives, you will see that a
number of sysadmins are using Excel for this, i.e., placing
their data in XL rows and columns rather than vbs arrays.
The advantage of XL is that you can see the data all-at-once
rather than a msgbox-at-a-time. You can also do other XL-magic
such as sorting, to tell which client is causing the most
trouble. It looks like you are using the console as a gui,
but XL is much more pleasant to look at.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)



.



Relevant Pages

  • Re: 2 Dimensional Array Question
    ... I've taken JW's suggestion about dimmensioning the array up front in advance ... if every server is actually reachable then ... just need to incorporate it into my Excel script ... ReDim Preserve arrSummary ...
    (microsoft.public.scripting.vbscript)
  • Re: file system index corruption problem
    ... Citrix Presentation Server 4.0 installed. ... In the end I discovered that running chkdsk /f every night would ... I have changed the array controller and one of the ... Temporarily install an 80 GByte IDE disk. ...
    (microsoft.public.win2000.file_system)
  • Re: Moving SCSI RAID array to new server
    ... Install the now blank array into the SBS2003, create the RAID volume, etc... ... I'd also probably lose the shirty SATA drives and eventually swing the whole ... > migrate the settings from the old server I just want to move the old RAID5 ...
    (microsoft.public.windows.server.sbs)
  • Re: StorEdge 3310, disk sets, 2 hosts
    ... >> Forget about the mirroring of the arrays via disksuite for the mean time. ... >> Assume for the moment that there is just 1 array, ... > reliable failovers involve replicating the data from server to server ... > - Sun Network Data Replicator ...
    (comp.unix.solaris)
  • Re: Excel and Shift-JIS
    ... the server to which we're uploading. ... an array of 8 bits per element, or in other words, a Byte array. ... Save from Excel as plain text, which it turns out is Shift-JIS on ... preserving the Japanese characters unlike doing the ...
    (microsoft.public.excel.programming)