开发者网络 动网主机 支持论坛 邮局 帮助
当前位置:网络学院ASP技术ASP应用 → 一个用application存数组的例子
一个用application存数组的例子
日期:2001年5月15日 作者:hooke(转) 人气:     [ ]
If you store an array in an Application object, you should not attempt to alter the elements of the stored array directly. For example, the following script does not work:

<% Application("StoredArray")(3) = "new value" %>

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 be included in the Application object collection, and would overwrite any information that had previously been stored at that location.

It is strongly recommended that if you store an array in the Application object, you retrieve a copy of the array before retrieving or changing any of the elements of the array. When you are done with the array, you should store the array in the Application object again, so that any changes you made are saved. This is demonstrated in the following scripts.

---file1.asp---
<%
'Creating and initializing the array.
dim MyArray()
Redim MyArray(5)
MyArray(0) = "hello"
MyArray(1) = "some other string"

'Storing the array in the Application object.
Application.Lock
Application("StoredArray") = MyArray
Application.Unlock

Server.Transfer("file2.asp")
%>

---file2.asp---
<%
'Retrieving the array from the Application Object
'and modifying its second element.
LocalArray = Application("StoredArray")
LocalArray(1) = " there"

'Printing out the string "hello there."
Response.Write(LocalArray(0)&LocalArray(1))

'Re-storing the array in the Application object.
'This overwrites the values in StoredArray with the new values.
Application.Lock
Application("StoredArray") = LocalArray
Application.Unlock
%>

(出处:chinaasp)

相关文章:
 
·asp中利用数组实现数据库记录的批量录入方法
·session变量中的数组如何引用
·如何避免重复定义数组
·通过数组给您的文件排序
·将数据库的内容读到二维数组并按指定列输出
·利用递归把多维数组转为一维数组的函数
·强大的数组功能(asp+程序数组功能调用)
·数组数据排序的程序例子
·读取目录下的文件得到一个数组
·在大型社区系统中用二维数组实现用户高级功能(1)
相关软件:
 
说明:本站部分内容收集于网络,如有侵犯您的权益请来信告知,我们会第一时间进行处理,谢谢
 → 特别推荐
 → 热点TOP10

关于本站 | 诚聘英才 | 业务合作 | 联系我们 | 广告合作 | 收藏本站

海口动网先锋网络科技有限公司版权所有
Copyright ? 2000 - 2003 AspSky.Net
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077