<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>

            ASP類代碼參考

            時間:2024-08-29 22:18:24 ASP 我要投稿
            • 相關推薦

            關于ASP模板類代碼參考

              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

              Could Not Load The File " & m_FileName & "!")

              End Function

              Private Sub ShowError(ByVal msg)

              m_LastError = msg

              Response.Write "Error ID : " & msg & ""

              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)

              Dim Matches

              m_RegExp.Pattern = "([sS.]*)"

              If Not m_BlockList.Exists(Parent) Then ShowError("0x12

              Undefined Block Tag " & Parent & "!")

              set Matches = m_RegExp.Execute(m_BlockList.Item(Parent))

              For Each Match In Matches

              m_BlockList.Add BlockTag, Match.SubMatches(0)

              m_BlockList.Item(Parent) = Replace(m_BlockList.Item(Parent), Match.Value, "{" & Name & "}")

              Next

              set Matches = nothing

              End Sub

              Public Sub set_var(ByVal Name, ByVal Value, ByVal AppEnd)

              Dim Val

              If IsNull(Value) Then Val = "" Else Val = Value

              If m_ValueList.Exists(Name) Then

              If AppEnd Then m_ValueList.Item(Name) = m_ValueList.Item(Name) & Val _

              Else m_ValueList.Item(Name) = Val

              Else

              m_ValueList.Add Name, Value

              End If

              End Sub

              Public Sub unset_var(ByVal Name)

              If m_ValueList.Exists(Name) Then m_ValueList.Remove(Name)

              End Sub

              Private Function InstanceValue(ByVal BlockTag)

              Dim keys, i

              InstanceValue = m_BlockList.Item(BlockTag)

              keys = m_ValueList.Keys

              For i=0 To m_ValueList.Count-1

              InstanceValue = Replace(InstanceValue, "{" & keys(i) & "}", m_ValueList.Item(keys(i)))

              Next

              End Function

              Public Sub parse(ByVal Name, ByVal BlockTag, ByVal AppEnd)

              If Not m_BlockList.Exists(BlockTag) Then ShowError("0x12

              Undefined Block Tag " & Parent & "!")

              If m_ValueList.Exists(Name) Then

              If AppEnd Then m_ValueList.Item(Name) = m_ValueList.Item(Name) & InstanceValue(BlockTag) _

              Else m_ValueList.Item(Name) = InstanceValue(BlockTag)

              Else

              m_ValueList.Add Name, InstanceValue(BlockTag)

              End If

              End Sub

              Private Function finish(ByVal content)

              Select Case m_Unknowns

              Case "keep" finish = content

              Case "remove"

              m_RegExp.Pattern = "{[^ trn}]+}"

              finish = m_RegExp.Replace(content, "")

              Case "comment"

              m_RegExp.Pattern = "{([^ trn}]+)}"

              finish = m_RegExp.Replace(content, "")

              Case Else finish = content

              End Select

              End Function

              Public Sub output(ByVal Name)

              If Not m_ValueList.Exists(Name) Then ShowError("0x13

              Could Not Find Tag " & Name & "!")

              Response.Write(finish(m_ValueList.Item(Name)))

              End Sub

              End Class

            【ASP類代碼參考】相關文章:

            防盜鏈接ASP函數實現代碼01-23

            ASP.NET連SQL7接口的源代碼06-06

            ASP網頁程序設計中10個非常有用的實例代碼08-12

            關于ASP.NET使用JavaScript顯示信息提示窗口實現原理及代碼05-09

            2016職稱英語綜合類A代碼12考試答案09-14

            過濾HTML代碼08-29

            ASP提速技巧08-05

            數控編程代碼大全05-18

            jquery提交按鈕的代碼07-28

            電腦藍屏代碼大全08-04

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院