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:<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 be included in the application object collection, and would overwrite any information that had previously been stored at that location.<br>
<br>
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.<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>
用application存数组的例子
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用application存数组的例子
相关推荐
-      ASP 简介
-      SQL注入天书 – ASP注入漏洞全接触
-      用.net 处理xmlHttp发送异步请求
-      asp.net创建文件夹的IO类的问题
-      如何实现ASP.NET网站个性化
-      关于ASP.NET调用JavaScript的实现
-      ASP利用Google实现在线翻译功能
-      Asp无组件生成缩略图
