programming-examples/asp/FilesMaths/Title Function.asp
2019-11-18 14:25:58 +01:00

20 lines
648 B
Plaintext

example usage:
Writes the hard coded HTML title of the document "file.htm".
<% = Title(Server.MapPath("/file.htm")) %>
source code:
<%
Private Function Title(ByVal pathname)
Dim objFSO, objFile, a, tmp, firstCt, secondCt
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(pathname, 1, False)
a = objFile.ReadAll()
objFile.Close
Set objFile = Nothing
Set objFSO = Nothing
firstCt = InStr(UCase(a), "<TITLE>") + 7
secondCt = InStr(UCase(a), "</TITLE>")
tmp = Mid( a, firstCt, secondCt - firstCt )
Title = CStr( Trim( tmp ) )
End Function
%>