asp中字符串转化为实体类的方法(优化篇,简单优化)
option explicit
dim str1,str2
str1 ="order|||shiyang:100,mayang:200"
str2 = "book|||shuming:计算机,dingjia:100"
'声明2个全局对象
'放弃了一开始希望用数组存储的方式,那个虽然效率更高,但是需要自定义的array_pushobj函数,所以此处不做讨论了
dim objname_g
dim classname_g
'返回实体类
function getObjmod(byval str)
dim classname,itemlist,i
dim execstr
classname = split(str,"|||")(0)
execstr = "class "&classname&chr(10)
itemlist = split(split(str,"|||")(1),",")
for i = 0 to ubound(itemlist)
execstr = execstr +"public "&split(itemlist(i),":")(0)&chr(13)&chr(10)
next
execstr = execstr&"end class"&chr(13)&chr(10)&_
" set objname_g = new "&classname
classname_g =classname
execute execstr
end function
'赋值
function getobjcon(byval str)
dim itemlist,i,execstr
if classname_g = split(str,"|||")(0) and isobject(objname_g) then
set getobjcon = objname_g
else
getObjmod( str)
set getobjcon = objname_g
end if
itemlist = split(split(str,"|||")(1),",")
for i = 0 to ubound(itemlist)
execstr = execstr +"getobjcon."&split(itemlist(i),":")(0)&" = """&split(itemlist(i),":")(1)&"""" &chr(13)&chr(10)
next
execute execstr
end function
'测试函数
sub ceshi3
dim i,o1
for i = 0 to 10000
set o1 = getobjcon(str1)
response.write o1.shiyang&"<br>"
next
set o1 = getobjcon(str2)
response.write o1.shuming&"<br>"
end sub
dim t1
t1=timer()
call ceshi3
response.write FormatNumber((timer()-t1),4,-1)
相关文档:
'使用FSO修改文件特定内容的函数
Function FSOchange(filename,Target,String)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)
FiletempData = objCountFile.ReadAll
objCountFi ......
用ASP制作张扬个性的调查系统(1)
随着网络的普及,网上调查往往能达到较好的效果。在自己的个人站点上放一个趣味问题调查板,着实能为网站添色不少;况且通过调查结果你能更多更准确了解网友对自己站点的看法。作为Webmaster,如果你的网站也需要就某个主题进行调查,而你又讨厌使用别人免费提供的调查 ......
目前在Internet上广泛使用的后台技术种类繁多,应用比较广泛的有CGI,ASP,PHP,JSP/JavaServlet,ColdFusion等。在这一节里,主要介绍几种在国内应用比较广泛的后台语言。
CGI,全称为Common Gateway Interface
CGI就是公共网关接口 (Common Gateway Interface) 的缩写。它是最早被用来建立动态网站的后台技术 ......
Windows7下IIS7的安装及ASP配置方法★
本文讲述了在Windows 7下如何安装IIS7,以及IIS7在安装过程中的一些需要注意的设置,以及在IIS7下配置ASP的正确方法。转载过程中不得以任何方式和方法用于商业用途,请注明出处。谢谢您的支持。祝您安装及调试成功。
注:本人安装的是Windows 7 RC 7100 32位中文旗舰版 。
在Window ......