Reads string between open and close HTML tag (between <...> and ), pass the file name, and the tag (without < or ) to get what is between those tags.
This was originally a function called Title that reads the title of an HTML page
<%
Private Function HTMLTag(pathname, BetweenTag)
dim FSO, objFile, a, tmp, firstCt, secondCt
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile(pathname, 1, False)
a = objFile.ReadAll()
objFile.Close
Set objFile = Nothing
Set FSO = Nothing
Tag1 = "<" & Ucase(BetweenTag) & ">"
Tag2 = "" & Ucase(BetweenTag) & ">"
firstCt = InStr(UCASE(a), Tag1) + Len(Tag1)
secondCt = InStr(UCASE(a), Tag2)
tmp = Mid( a, firstCt, secondCt - firstCt )
Title = CStr( Trim( tmp ) )
End Function
' ======================= Original function
' Example of calling Original function
' Title(server.mappath("/file.htm"))
' Original function was Title
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), "") + 7
secondCt = InStr(UCASE(a), " ")
tmp = Mid( a, firstCt, secondCt - firstCt )
Title = CStr( Trim( tmp ) )
End Function
%>
Private Function HTMLTag(pathname, BetweenTag)
dim FSO, objFile, a, tmp, firstCt, secondCt
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = FSO.OpenTextFile(pathname, 1, False)
a = objFile.ReadAll()
objFile.Close
Set objFile = Nothing
Set FSO = Nothing
Tag1 = "<" & Ucase(BetweenTag) & ">"
Tag2 = "" & Ucase(BetweenTag) & ">"
firstCt = InStr(UCASE(a), Tag1) + Len(Tag1)
secondCt = InStr(UCASE(a), Tag2)
tmp = Mid( a, firstCt, secondCt - firstCt )
Title = CStr( Trim( tmp ) )
End Function
' ======================= Original function
' Example of calling Original function
' Title(server.mappath("/file.htm"))
' Original function was Title
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), "
secondCt = InStr(UCASE(a), "
tmp = Mid( a, firstCt, secondCt - firstCt )
Title = CStr( Trim( tmp ) )
End Function
%>
pathname, BetweenTag
<% = Title(server.mappath("/file.htm"), "Title") %>
Views 457 Downloads 155