首页 > 网站 > 建站经验 > 正文

ASP模板、类代码

2019-11-02 14:51:23
字体:
来源:转载
供稿:网友

 Class Template

Private m_FileName, m_Root, m_Unknowns, m_LastError, m_HaltOnErr
Private m_ValueList, m_BlockList
Private m_RegExp
Private Sub Class_Initialize
Set m_ValueList = CreateObject("Scripting.Dictionary")
Set m_BlockList = CreateObject("Scripting.Dictionary")
set m_RegExp = New RegExp
m_RegExp.IgnoreCase = True
m_RegExp.Global = True
m_FileName = ""
m_Root = "."
m_Unknowns = "remove"
m_LastError = ""
m_HaltOnErr = true
End Sub

Private Sub Class_Terminate
Set m_RegExp = Nothing
Set m_BlockMatches = Nothing
Set m_ValueMatches = nothing
End Sub

Public Property Get ClassName()
ClassName = "Template"
End Property

Public Property Get Version()
Version = "1.0"
End Property
Private Function LoadFile(ByVal chartype)
Dim Filename, fso, hndFile
Filename = m_Root
If Right(Filename, 1)<>"/" And Right(Filename, 1)<>"" Then Filename = Filename & "/"
Filename = Server.MapPath(Filename & m_FileName)
Set StreamObject = Server.CreateObject("Adodb.Stream")
StreamObject.Type = 1
StreamObject.Mode = 3
StreamObject.Open
StreamObject.Position = 0
StreamObject.LoadFromFile Filename
StreamObject.Position = 0
StreamObject.Type = 2
StreamObject.CharSet = chartype
LoadFile = StreamObject.readtext()
If LoadFile = "" Then ShowError("0x11<br>Could Not Load The File " & m_FileName & "!")
End Function

Private Sub ShowError(ByVal msg)
m_LastError = msg
Response.Write "<span style=""font-size:12px;color:red"">Error ID : " & msg & "</span>"
If m_HaltOnErr Then Response.End
End Sub

Public Sub set_root(ByVal Value)
m_Root = Value
End Sub
Public Function get_root()
get_root = m_Root
End Function
Public Property Let Root(ByVal Value)
set_root(Value)
End Property
Public Property Get Root()
Root = m_Root
End Property

Public Sub set_file(ByVal handle,ByVal filename,ByVal chartype)
m_FileName = filename
m_BlockList.Add Handle, LoadFile(chartype)
End Sub
Public Function get_file()
get_file = m_FileName
End Function
Public Sub set_unknowns(ByVal unknowns)
m_Unknowns = unknowns
End Sub
Public Function get_unknowns()
get_unknowns = m_Unknowns
End Function
Public Property Let Unknowns(ByVal unknown)
m_Unknowns = unknown
End Property
Public Property Get Unknowns()
Unknowns = m_Unknowns
End Property

Public Sub set_block(ByVal Parent, ByVal BlockTag, ByVal Name)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表