The Utility Script Library File

This section describes the utility script library file to be used as an include file for the main ASP script page.

In order to make the guest book main script easier to maintain, I have moved all utility functions into a separate library file, _library.inc:

Function myTrim(sText,nLen)
   myTrim = sText
   If myTrim <> "" Then
      myTrim = Trim(sText)
      If Len(myTrim) > nLen Then
         myTrim = Mid(myTrim, 1, nLen)
      End If
   End If
End Function

Function removeHTML(strText)
   Dim RegEx
   Set RegEx = New RegExp
   RegEx.Pattern = "<[^>]*>"
   RegEx.Global = True
   RemoveHTML = RegEx.Replace(strText, "")
End Function

Function htmlNotice(sText)
   Response.Write("<table class=hy_notice cellspacing=0" _
      & " cellpadding=5>")
   Response.Write("<tr><td>" & sText & "</td></tr>")
   Response.Write("</table>")
End Function

Function htmlError(sText)
   Response.Write("<table class=hy_error cellspacing=0" _ 
      & " cellpadding=5>")
   Response.Write("<tr><td>" & sText & "</td></tr>")
   Response.Write("</table>")
End Function

Function myDump
   aKeys = hgRqParam.Keys()
   ogDebug.WriteLine("Values in hgRqParam:")
   For i=0 To hgRqParam.Count-1
      k = aKeys(i)
      ogDebug.WriteLine(k & " = (" & hgRqParam.Item(k) & ")")
   Next

   aKeys = hgPgParam.Keys()
   ogDebug.WriteLine("Values in hgPgParam:")
   For i=0 To hgRqParam.Count-1
      k = aKeys(i)
      ogDebug.WriteLine(k & " = (" & hgPgParam.Item(k) & ")")
   Next
End Function
%>

Last update: 2006.

Table of Contents

 About This Book

 ASP (Active Server Pages) Introduction

 IIS (Internet Information Services) 5.0

 MS Script Debugger

 VBScript Language

 ASP Built-in Run-time Objects

 ASP Session

 Creating and Managing Cookies

 Managing Sessions with and without Cookies

 scrrun.dll - Scripting Runtime DLL

 Managing Response Header Lines

 Calculation Speed and Response Time

 ADO (ActiveX Data Object) DLL

 Working with MS Access Database

Guest Book Application Example

 Design Overview

 Database Tables

 Configuration File

 Page Layout Template File

 Guest book Main Script

The Utility Script Library File

 Data Submission Issues

 Webmaster Administration Page

 References

 PDF Printing Version