`

一个用application存数组的例子

ASP 
阅读更多
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
%>

分享到:
评论

相关推荐

    icePdf_To_Image_5.1.2.zip

    这是一个完整的例子程序,包含修改的代码,效果很不错 ICEpdf Core 5.1.2 P02 去水印的例子,里面有修改好的代码和例子程序 去水印的方法: 参考http://blog.csdn.net/wangpeng468/article/details/37810445 我是...

    office 办公软件中利用VBA(Visual Basic for Application)宏

    Set newDoc = Documents.Add '用Documents.Add增加一个新文档 With newDoc .SaveAs FileName:="D:/txtal.doc" '新文档保存的完整路径 End With ActiveDocument.close '关闭新建的文档 With Dialogs...

    跨页传值的常用方法 东东

    下面是一个例子:  a.ASPx的C#代码 private void Button1_Click(object sender, System.EventArgs e) { string s_url; s_url = "b.aspx?name=" + Label1.Text; Response.Redirect(s_url); } b.aspx中C#代码 ...

    java 编写文件上传类简单易用

    用 Java 编写的、协议和平台都独立的服务器端组件,使用请求/响应的模式,提供了一个基于 Java 的服务器解决方案。本文将从文件传输的基本原理入手,分析如何用 java进行文件的上传,并提出解决方案。 一、基本...

    MongoDB数据库设计.pptx

    One-to-Squillions 我们用一个收集各种机器日志的例子来讨论一对非常多的问题。由于每个mongodb的文档有16M的大小限制,所以即使你是存储ObjectID也是不够的。我们可以使用很经典的处理方法"父级引用"---用一个文档...

    菜鸟谈VBA最最基础入门

    19、[小试牛刀]制作一个个性化的欢迎界面  20、处理单元格数据(复制、剪切、删除 21、Range对象的End 属性(带作业) 22、花名册分类(实例) 23、花名册汇总(实例 24、新建工作表 25、认识数组(一) 26、...

    java-servlet-api.doc

    然而,一个映射可能是由一个URL和许多Servlet实例组成,例如:一个分布式的Servlet引擎可能运行在不止一个的服务器中,这样的话,每一个服务器中都可能有一个Servlet实例,以平衡进程的载入。作为一个Servlet的...

    MFC教程入门知识全集.rar

    2.3.2.1 如何设计一个窗口类——步骤1 2.3.2.2 注册设计好的窗口类——步骤2 2.3.2.3 创建窗口——步骤3 2.3.2.4 显示创建的窗口——步骤4 2.3.3 消息循环 2.3.4 完成回调函数 2.4 程序编写操作步骤与实验 ...

    android 入门笔记

    1. 开发环境配置 2 1) Eclipse下载地址: 2 2) Android SDK下载地址: 2 3) Mars教学视频地址: 2 ...16. 数组方式构造下拉框 18 17. 用户登录例子: 19 18. 用户登录对话框 22 19. 下拉框 动态数据 24

    java视频教程Day01 免费

    9. 图形用户界面编成 (安排一个游戏例子,坦克或者飞机游戏;以及一个CS结构的QQ) 10. Applet (Applet编程) 11. Multi-Thread(多线程) 12. I/O and File (输入/输出流及文件) 13. Networking (网络编程) ...

    AngularJS模块详解及示例代码

    AngularJS支持模块化的方法。模块用于单独的逻辑表示服务,控制器,应用程序等,并保持代码的整洁。我们在单独的js文件中定义的模块,并将其命名为按照module.js文件形式。...我们已经通过了一个空数组给它。此数组通常

    Delphi多线程编程之三 同步读写全局数据

    如果把初始化数组的代码放在临界区内,另一个线程在第一个线程处理完之前是不会被执行的。 使用临界区的步骤: 1、先声明一个全局变量类型为TRTLCriticalSection; 2、在线程Create()前调用...

    net学习笔记及其他代码应用

    6.如果在一个B/S结构的系统中需要传递变量值,但是又不能使用Session、Cookie、Application,您有几种方法进行处理? 答 : this.Server.Transfer 7.请编程遍历页面上所有TextBox控件并给它赋值为string.Empty? ...

    在同步代码结束后,使用ReleaseMutex(THandle

    如果把初始化数组的代码放在临界区内,另一个线程在第一个线程处理完之前是不会被执行的。 使用临界区的步骤: 1、先声明一个全局变量类型为TRTLCriticalSection; 2、在线程Create()前调用...

    基于SIP开发软件电话的一些资源(转自YOUTOO)

    需要有实际的例子程序参考学习,而最好的例子就是同样官方发布的oSIP的扩展开发库exosip2,使用exoSIP可以很方便地快速创建一个完整的SIP程序(只针对性地适用于SIP终端开发用,所以我们这里只是用它...

    Knockout API 中文版

    (developed BDD-style) means its correct functioning can easily be verified on new browsers and platforms 开发人员如果用过Silverlight或者WPF可能会知道KO是MVVM模式的一个例子。如果熟悉 Ruby on Rails 或...

    Java2游戏编程.pdf

    中文名: Java2游戏编程 ...附录C 使用JNI创建一个gamepad阅读器 附录D 使用.JAR文件来部署Java applet 附录E 正确运行Java 2 applet 附录F Magic游戏引擎源码清单 附录G 更多的资源 附录H 配书光盘中有些什么

    AS3-DomainMemoryManager:Adobe AIRFlash中用于域内存访问的管理器

    AS3-DomainMemoryManager 用于在Adobe AIR / Flash中访问域内存的管理器。 该项目是根据MIT许可... DomainMemory的使用存在一些问题: 只能将一个字节数组同时分配给ApplicationDomain.domainMemory 在ApplicationDo

    Tcl_TK编程权威指南pdf

    一个阶乘的例子 更多有关变量的知识 更多有关数学表达式的内容 注释 有关替换与分组的总结 要点 参考 第2章 开始使用 source命令 unix上的tcl脚本程序 .windows 95的开始菜单 macintosh与resedit ...

    Java开发技术大全 电子版

    10.2一个关于泛型的简单例子305 10.3带两个类型参数的泛型类308 10.4有界类型309 10.5通配符参数311 10.6泛型方法313 10.7泛型接口315 10.8泛型类的继承317 10.8.1以泛型类为父类317 10.8.2以非泛型类为父类...

Global site tag (gtag.js) - Google Analytics