Kolla i mitt script, där kan du plocka ut precis detta ur koden...
http://script.webforum.nu/wf/Forum1/HTML/000021.html
------------------
Jourhavande Vide
7 svar · 196 visningar · startad av qwerty
Har gjort en applikation där man kan söka på ord på hela min webplats efter en artikel på www.4guysfromrolla.com/webtech/120499-1.shtml
Nu undrar jag om det finns något bra sätt att när sökresultatet visas, kunna visa även vad det är för <title> på dokumentet och inte bara filnamnet.
/Tack på förhand
------------------
Qwerty
Den som provar han testar...
[Redigerat av qwerty den 21 feb 2001]
Kolla i mitt script, där kan du plocka ut precis detta ur koden...
http://script.webforum.nu/wf/Forum1/HTML/000021.html
------------------
Jourhavande Vide
På den här raden:
Set regEx = New RegExp
Får jag felet:
Variable is undefined:'regEx'
Vaffö då.
------------------
Qwerty
Den som provar han testar...
Undefined betyder Odefinierad på svenska... Alltså tycker scriptet att RegEx inte är Dimmat... Har du satt Option Explicit på din sida?
------------------
Jourhavande Vide
och för att eventuellt undvika en följdfråga, skriv såhär övers i ditt dokumet:
<% Option Explicit %>
<% Dim regEx %>
MVH
------------------
nakoz :)
....lite bättre att skriva så här:
<%
Option Explicit
Dim regEx
%>
------------------
Private Function OutPut(ByRef sString)
OutPut = "Who gives ..." & sString
End Function
hehe... det buggar fett med mitt pws om jag inte har option explicit i en "egen" tagg... men om de funkar för andra (vilket jag inte trodde :e) så e PatrikBs kod helt klart bättre :)
MVH
------------------
nakoz :)
OK, så här är det!
Jag har försökt i flera timmar nu använda delar av Vides scipt och försökt stoppa in det på rätt ställe, anpassa koden osv. Så här ser min sökfunktion ut nu, när jag gjort den efter artikeln. Skulle någon vänlig själ villa tipsa mig om hur jag ska göra. Jag är nöjd med sökresultatet, men vill altså att den ska skriva ut <title> iställer för untitled.
Function GetFiles(objFolder, aLookFor, strLF, bolLFFound,bolAnd, iCount)
If Left(objFolder.Name,1) = "_" then exit function
Const iListPerPage = 9
if iCount > iListPerPage then Exit Function
'Now, loop through each file
Dim objFile, objTextStream, objFSO, strContents, iUBound, iLoop, bolValid
Dim strTitle, iPos, strDesc
iUBound = UBound(aLookFor)
For Each objFile in objFolder.Files
'Do we need to search this file?
If UCase(Right(objFile.Name,4)) = ".HTM" OR UCase(Right(objFile.Name,4)) = ".ASP" then
If bolLFFound then
if objFile.Size > 0 then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile(objFile.Path,1)
strContents = objTextStream.ReadAll
objTextStream.Close
Set objFSO = Nothing
if bolAnd then bolValid = True else bolValid = False
For iLoop = 0 to iUBound
If InStr(1,strContents,aLookFor(iLoop),1) then
if Not bolAnd then bolValid = True
Else
If bolAnd then bolValid = False
End If
Next
If bolValid then
iPos = InStr(1,strContents,"<!--TITLE:")
If iPos = 0 then
strTitle = "Untitled (" & objFile.Name & ")"
strDesc = ""
Else
strTitle = Mid(strContents,iPos+10,InStr(iPos,strContents,"-->")-iPos-10)
iPos = InStr(iPos,strContents,"<!--DESC:")
If iPos = 0 then
strDesc = ""
Else
strDesc = Mid(strContents,iPos+9,InStr(iPos,strContents,"-->")-iPos-9)
End If
End If
Response.Write "<A HREF=""" & FormatURL(objFile.Path) & """>" & _
strTitle & "</A><BR>" & vbCrLf
Response.Write "<FONT SIZE=2>" & strDesc
Response.Write "</FONT><P>" & vbCrLf
iCount = iCount + 1
End if
If iCount > iListPerPage then
strLF = FormatURL(objFile.Path)
exit function
End If
End If
Elseif FormatURL(objFile.Path) = strLF then
bolLFFound = True
End If
End if
Next
Dim objSubFolder
For Each objSubFolder in objFolder.SubFolders
GetFiles objSubFolder,aLookFor,strLF,bolLFFound,bolAnd,iCount
Next
End Function
------------------
Qwerty
Den som provar han testar...