Re: 2 Dimensional Array Question
- From: Jeff Lacy <JeffLacy@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Dec 2006 11:08:00 -0800
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
work*** 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 work*** or opening a second
work*** for just this data and then import it into the first work*** 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)
- Follow-Ups:
- Re: 2 Dimensional Array Question
- From: Richard Mueller
- Re: 2 Dimensional Array Question
- References:
- 2 Dimensional Array Question
- From: Jeff Lacy
- Re: 2 Dimensional Array Question
- From: mr_unreliable
- 2 Dimensional Array Question
- Prev by Date: Re: Easy or Not? Adding spell-check to an existing InDesign VBScript
- Next by Date: Re: 2 Dimensional Array Question
- Previous by thread: Re: 2 Dimensional Array Question
- Next by thread: Re: 2 Dimensional Array Question
- Index(es):
Loading