在gloable.asa中进行了如上的定义后,我们就可以在后面的页面中应用了。我们假设先有一个用户的登陆确认(从数据库中确认用户的信息)大致的代码如下:
| 以下为引用的内容: <!-- #include virtual="/chat/inc/Convert.inc" --> <%'将欢迎的内容记入application数组并调整顺序%> <!-- #include virtual="/chat/inc/RoomRefresh.inc" --> <!-- #include virtual="/chat/inc/Logname.inc" --> <%'将姓名记入application数组%> <% if request.servervariables("Request_Method")="POST" and session("sChater_Name")="" then name=request.form("txtName") pass=request.form("txtPass") set res=session("res") sql="Select * From Chater_Message Where Name='"&name&"' And Pass='"&pass&"';" res.open sql,,3,3 if res.BOF then response.write "Login Failed"&"<br>" response.write "<a href="&chr(34)&"LoginPage.htm"&chr(34)&">"&"请重新登陆"&"</a>" res.close else session("sChater_Name")=name Welcome_Message="common"&","&"系统"&","&"所有人"&","&"<font color="&chr(34)&"#ff98ff"&chr(34)&">"&"各位看官,"&session("sChater_Name")&"来也"&"</font>"&"<br>" '这句话请大家一定要注意,如果你读了我的上一篇文章你应该知道是什么意思。 application.lock call convert(Welcome_Message) call logname(session("sChater_Name"),session("sRoom_Name")) call roomrefresh() application.unlock res.close response.redirect "ChatPage.htm" end if end if %> |
下面是三个关键的子程序,在后面也有大量的应用。
| 以下为引用的内容: convert.inc <% sub convert(Message) dim tmpChat_Value() pChat_Value=application(session("sRoom_Name")&"_Value") pChat_Number=application(session("sRoom_Name")&"_Number") '由于使用了session("sRoom_Name")来保存当前的房间名,因此可以被每个房间的 提交子过程调用。 if pChat_Number>=50 then pChat_Number=0 end if redim tmpChat_Value(pChat_Number) for i=0 to pChat_Number tmpChat_Value(i)=pChat_Value(i) next pChat_Value(0)=Message for i=0 to pChat_Number pChat_Value(i+1)=tmpChat_Value(i) next pChat_Number=pChat_Number+1 application(session("sRoom_Name")&"_Value")=pChat_Value application(session("sRoom_Name")&"_Number")=pChat_Number end sub %> logname.inc |
ljj1689整理

RSS订阅