⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 template.asp

📁 航空订票系统基于asp.net和sql2005包含数据库和图片
💻 ASP
字号:
<%
'================ 模板操作类 开始 ================
Class Cls_Template
  '-------- 载入模板文件 --------
  Public Function Load(ByVal strTemplateFileName)
    Dim oFso, oFile, strStreamOut
    'Read Template File
    Set oFso = CreateObject("Scripting.FileSystemObject")
    If not oFso.FileExists(strTemplateFileName) then
      Response.Write "Load Template Error: <br>File does not exist!<br>" & strTemplateFileName
      Response.End
    End if
    Set oFile = oFso.OpenTextFile(strTemplateFileName, 1) 'ForReading; NotCreate; OpenedAsASCII
    strStreamOut = oFile.ReadAll()
    oFile.Close
    Set oFile = Nothing
    Set oFso = Nothing
    'Return Value
    Load = strStreamOut
  End Function

  '-------- 获取文件块起始标记位 --------
  Private Function GetPartStartPosition(ByVal strTemplateStream, ByVal strBoundaryStart)
    strBoundaryStart = strBoundaryStart & ""
    If strBoundaryStart = "" Then
      GetPartStartPosition = 1
    Else
      GetPartStartPosition = InStr(1, strTemplateStream, strBoundaryStart, 1)
    End if
  End Function

  '-------- 获取文件块结束标记位 --------
  Private Function GetPartClosePosition(ByVal strTemplateStream, ByVal strBoundaryClose)
    strBoundaryClose = strBoundaryClose & ""
    If strBoundaryClose = "" Then
      GetPartClosePosition = Len(strTemplateStream) + 1
    Else
      GetPartClosePosition = Instr(1, strTemplateStream, strBoundaryClose, 1)
    End if
  End Function

  '-------- 获取模板文件块 --------
  Public Function GetPart(ByVal strTemplateStream, ByVal strBoundaryStart, ByVal strBoundaryClose)
    Dim nStartPos, nClosePos, rtnVal
    'Get Start Position
    nStartPos = GetPartStartPosition(strTemplateStream, strBoundaryStart)
    'Get End Position
    nClosePos = GetPartClosePosition(strTemplateStream, strBoundaryClose)
    'Get Part Content
    If nClosePos > nStartPos Then
      rtnVal = Mid(strTemplateStream , nStartPos + Len(strBoundaryStart), nClosePos - nStartPos - Len(strBoundaryStart))
    Else
      rtnVal = ""
    End if
    'Return Value
    GetPart = rtnVal
  End Function

  '-------- 模板文件内容块替换 --------
  Public Function ReplacePart(ByVal strTemplateStream, ByVal strBoundaryStart, ByVal strBoundaryClose, ByVal strDestStream)
    Dim nStartPos, nClosePos, rtnVal
    'Get Start Position
    nStartPos = GetPartStartPosition(strTemplateStream, strBoundaryStart)
    if nStartPos = 0 then nStartPos = 1
    'Get End Position
    nClosePos = GetPartClosePosition(strTemplateStream, strBoundaryClose)
    if nClosePos = 0 then nClosePos = 1
    'Get Part Content
    If nClosePos > nStartPos Then
      rtnVal = Mid(strTemplateStream, 1, nStartPos-1) + strDestStream + Mid(strTemplateStream, nClosePos + Len(strBoundaryClose))
    Else
      rtnVal = ""
    End if
    'Return Value
    ReplacePart = rtnVal
  End Function

  '-------- 模板文件宏代换 --------
  Public Function ReplaceMacros(ByVal strTemplateStream, ByRef arrayMacros)
    Dim mItem
    'Replace Macros
    for each mItem in arrayMacros
      strTemplateStream = Replace(strTemplateStream, mItem, arrayMacros(mItem) & "")
    next
    'Return Value
    ReplaceMacros = strTemplateStream
  End function
End Class
'================ 模板操作类 结束 ================
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -