Examples of using application to save arrays

Source: Internet
Author: User
Tags array arrays
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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.