aa wrote:
Is it correct to think that after reducing the populated array's size
from say, 10 to 5 with
redim preserve myArray(i)
an attempt to access an element above the fifth does not cause a
compillation error "array out of script", but returns whatever
heppened to be written in that memory address (in particular it might
return the correct values of those elements before re-dimentioning)?
This seems to be the case in my code, yet I wanted to make sure that
this is not the result of some other side effect
Nope. As expected, this code raises the "Subscript out of range: '5'" error
on my machine:
<%
dim ar(),i
redim ar(10)
for i=0 to 10
ar(i)=1
next
redim preserve ar(4)
Response.Write ar(5)
Response.End
%>
If you are using "on error resume next", and you attempt to redim an array
that cannot be redim'ed (the only redimmable arrays are those declared with
the syntax shown in my dim statement above), you may not receive the error
message, and the array will be unaffected by the redim statement. That is
what happens when I change my code to this:
<%
on error resume next
dim ar(10), i
for i=0 to 10
ar(i)=i
next
redim preserve ar(4)
for i = 0 to 10
Response.Write ar(i) & "<BR>"
next
Response.End
%>
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"