[thelist] [ASP] Empty arrays in different versions
Peter Wakeford
peterwakeford at intekom.co.za
Wed Oct 15 03:51:13 CDT 2003
Josh,
I tried trapping the error in the example you provided, and it's returning
an err number of 9 for me.
Dim myarray()
on error resume next
ReDim Preserve myarray(UBound(myarray) + 1)
if err.number<>0 then
redim myarray(0)
end if
If you think about it though, the problem makes sense. The ubound function
is suppose to return the largest available subscript for the array, but b/c
the array is declared initially as dynamic with no dimensions, no
subscripts should exist either. Just my 2p worth.
----- Original Message -----
From: "Joshua Olson" <joshua at waetech.com>
To: <thelist at lists.evolt.org>
Sent: Wednesday, October 15, 2003 3:26 AM
Subject: Re: [thelist] [ASP] Empty arrays in different versions
> ----- Original Message -----
> From: "Peter Wakeford" <peterwakeford at intekom.co.za>
> Sent: Tuesday, October 14, 2003 7:31 PM
>
>
> > Josh,
> > here's the official MS VB scripting documentation for it below. The
> function
> > should always return false if the expression contains more than one
> > variable. In the example it's a variant array (use typename() or
> vartype()
> > to determine)
>
> Hiya Peter,
>
> That's odd. On one of my machines IsEmpty returns true if the array has
no
> elements in it--on the other it returns false. I guess I go with the
> documented version. :-)
>
> So, let's say you wanted to initialize an array using:
>
> Dim myarray()
>
> And then later wanted to add one element to it. Typically I'd do
something
> like:
>
> ReDim Preserve myarray(UBound(myarray) + 1)
> myarray(UBound(myarray)) = "Whatever"
>
> But, if myarray is not initalized in the first place (like before the
first
> call to ReDim) then UBound will fail during the ReDim. I tried an
> alternative way of trapping the error and setting it explicitely to "ReDim
> myarray(0)" in the event of an error, but Err.Number was always 0... any
> other options other than maintaining another variable with the length of
the
> array?
>
> Thanks.
>
> <><><><><><><><><><>
> Joshua Olson
> Web Application Engineer
> WAE Tech Inc.
> http://www.waetech.com
> 706.210.0168
>
> --
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
>
More information about the thelist
mailing list