下面,我们用这个“注册表”类来写一个简单的“计数器”应用,代码如下:
pagecount.asp:
<!– #include file="registry_class_inc.asp" –>
<%
dim reg
set reg = new registryobject
reg.path = server.mappath("pagecount.xml")
const basecount = 8000 计数器基数
dim count
count = reg.readvalue("pagecount", "common", "count") 读取原有计数
if isnumeric(count) then
count = clng(count)
else
count = basecount
end if
if count < basecount then count = basecount
count = count + 1
reg.savevalue "pagecount", "common", "count", count 保存新计数
set reg = nothing
response.write("document.write (您是第 " & count & " 位来访者);") 显示计数
%>
test.htm:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>测试xml计数器</title>
</head>
<body>
<script language="javascript" src="pagecount.asp"></script>
</body>
</html>
相关文章:
给网站添加一个注册表 之 “类的设计”
给网站添加一个注册表 之 “类的实现”
