Jag tycker dina IF-satser ser väldigt konstiga ut i visa-funktionen. Kolla igenom dom noga för du har troligen glömt minst ett endif.
Eller så har du klistrat in dom fel. ;)
Allå!
Så här ser min asp-fil med funktioner ut:
<%
'------------------------------------------------------------- SKAPA KLICKBARA LÄNKAR
Function Visa(s)
On error resume next
Set objRE = new RegExp
objRE.IgnoreCase = True : objRE.Global = True
objRE.Pattern = "(http:\/\/|www\.)(\w|\&|\:|\;|\.|\/|\?|\~|\=|-)+"
Set m = objRE.Execute(s)
For Each o In m
If Right(o.Value, 1)="." Or Right(o.Value, 1)="!" Or Right(o.Value, 1)="?" Or Right(o.Value, 1)="," Then
If Left(o.Value, 3) = "www" Then s = Replace(s, o.Value, "<A HREF=""http://" & Left(o.Value, Len(o.Value)-1) & """ target=""_blank"">" & Left(o.Value, Len(o.Value)-1) & "</A>" & Right(o.Value, 1)) Else s = Replace(s, o.Value, "<A HREF=""" & Left(o.Value, Len(o.Value)-1) & """>" & Left(o.Value, Len(o.Value)-1) & "</A>" & Right(o.Value, 1))
Else
If Left(o.Value, 3) = "www" Then s = Replace(s, o.Value, "<A HREF=""http://" & o.Value & """ target=""_blank"">" & o.Value & "</A>") Else s = Replace(s, o.Value, "<A HREF=""" & o.Value & """ target=""_blank"">" & o.Value & "</A>")
End If
Next
Set objRE = Nothing
'----------- Tillåten HTML kod
'[B][ och ] är bytt mot ( och ) eftersom forumet annars tolkar koden[/B]
s = Replace(s, "(B)", "<b>")
s = Replace(s, "(/B)", "</b>")
s = Replace(s, "(I)", "<i>")
s = Replace(s, "(/I)", "</i>")
s = Replace(s, "(U)", "<u>")
s = Replace(s, "(/U)", "</u>")
s = Replace(s, vbCrLf, "<br>")
s = Replace(s,"","") '[B]Denna rad skall ersätta en fyrkant, vilket inte syns i forumet[/B]
Visa = s
End Function
'------------------------------------------------------------- KONVERTERA FORM-INNEHÅLL FÖR DB-UPPDATERING
Function Uppdatera(sfix)
sfix = Replace(Trim(sfix), "'", "''")
sfix = Replace(sfix, "|", "")
Uppdatera = sfix
End Function
'------------------------------------------------------------- KORTA NER EN TEXT
Function WordLeft(strText, intNoOfWords)
Dim arrText, strippedText, I
arrText = Split(strText, " ")
If UBound(arrText) => intNoOfWords Then
For I = 0 To (intNoOfWords - 1)
If i = (intNoOfWords - 1) Then
strippedText = strippedText & arrText(i) & "..."
Else
strippedText = strippedText & arrText(i) & " "
End if
Next
Else
strippedText = strText
End If
WordLeft = strippedText
End Function
%>
Jag länkar in den med:
<!-- #include file="inst/funktioner.asp" -->
...och skriver så här för att nyttja funktionen Visa() som bör ge klickbara länkar och ersätter med <b>:
If Not RS.EOF Then
strPresentation = RS("Presentation")
If Len(strPresentation) > 0 Then
Response.Write Visa(Server.HTMLEncode(strPresentation))
End If
End If
Alla HTML-formateringar fungerar som de skall, dock ej funktionen som skall ge klickbara länkar. Den har tidigare fungerat på andra hemsidor men jag har nu lagt in flera funktioner (html-konventeringen har dock alltid funnits där, fast den har nu utökats) och bara bytt namn på den. Hittar ni något fel?
