application| array If You store a Application object, you should not attempt to alter the elements Array directly. For example, the following script does not work:<br>
<br>
<% application ("StoredArray") (3) = "New Value"%><br>
<br>
This is because the Application object is implemented as a collection. The array element StoredArray (3) does not receive the new value. Instead, the value would is included in the Application object collection, and would overwrite any information of that had PR eviously been stored at that location.<br>
<br>
It is strongly recommended so if you store an array in the Application object, and you retrieve a copy of the array before r Etrieving or changing any of the elements of the array. When you are do with the array, your should store the array in the Application object again, so and any changes you made are saved. This is demonstrated in the following scripts.<br>
<br>
---file1.asp---<br>
<%<br>
' Creating and initializing the Array.<br>
Dim myarray () <br>
Redim myarray (5) <br>
MyArray (0) = "Hello" <br>
MyArray (1) = "Some other string" <br>
<br>
' Storing the array in the application object.<br>
Application.lock<br>
Application ("StoredArray") = myarray<br>
Application.unlock<br>
<br>
Server.Transfer ("file2.asp") <br>
%><br>
<br>
---file2.asp---<br>
<%<br>
' Retrieving the array from the application object<br>
' and modifying its second element.<br>
LocalArray = Application ("StoredArray") <br>
LocalArray (1) = "There" <br>
<br>
' Printing out the string ' Hello there. <br>
Response.Write (LocalArray (0) &localarray (1)) <br>
<br>
' Re-storing the array in the application object.<br>
' This overwrites the values in StoredArray with the new values.<br>
Application.lock<br>
Application ("StoredArray") = localarray<br>
Application.unlock<br>
%><br>
<br>