AampyMedlem sedan feb. 20011 498 inlägg Trådstart#1 Jag vill att
ska bli till <img src="images/bild3.gif">
Jag har lagt denna kod högst upp på sidan
text = REPLACE(text, ":)", "<img src='images/bild3.gif'")
Räcker den eller måste jag lägga till något mer?
JjorgenMedlem sedan feb. 20012 412 inlägg Hej, misstänmker att du ska ha fler än 1 smiley, därför är det bättre om du gör en funktion av det:
Function Free(txt)
txt = Replace(txt, ":)", "<img src=""images/bild3.gif"" alt=""Ikon"">")
Free = txt
End Function
bara att lägga till så många du vill sedan.
red: blev en fnutt förmycket
mvh Jörgen 
AampyMedlem sedan feb. 20011 498 inlägg Jag får detta felmeddelande:
Feltyp:
Kompileringsfel i Microsoft VBScript (0x800A03EA)
Syntaxfel
/Ampy/chat1234/room.asp, line 8
Function Free(txt)
Rad 8:
Function Free(txt)
AampyMedlem sedan feb. 20011 498 inlägg <!--#include file="functions.inc.asp"-->
<%
Function ParseText(strText) 'Skriver man en pipe | i texten så kommer allt efter pipen att försvinna från meddelandet!
strSplitted = Split(strText, "|")
Function Free(txt)
txt = Replace(txt, ":)", "<img src=""images/bild3.gif"" alt=""Ikon"">")
Free = txt
End Function
%>
<table>
<tr>
<%
If strSplitted(1) = "public" Then 'Meddelande till alla
ParseText = "<td width='600' bgcolor='#FFEFCE'><b><font color='#000080'>" & strSplitted(2) &
"</font></b><i><font color='#999999'> - (" & strSplitted(0) & ")</i></font>: " &
CheckForLinks(Server.HTMLEncode(strSplitted(3))) & "</td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionlogin" Then 'Nån har loggat in
ParseText = "<tr><td width='600' bgcolor='#FFE784'><b><font color=""#000000"">" &
Server.HTMLEncode(strSplitted(2)) & " stiger in i chatten (" & strSplitted(0) & ")</b></font></td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionlogoff" Then 'Nån har loggat ut
ParseText = "<tr><td width='600' bgcolor='#FFE784'><b><font color=""#000000"">" &
Server.HTMLEncode(strSplitted(2)) & " har lämnat chatten (" & strSplitted(0) & ")</font></b></td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionkicked" Then 'Nån har kickats ut ur chatten av en administratör
ParseText = "<tr><td width='600' bgcolor='#FFE784'><font color=""#aaaaaa"">[" &
Server.HTMLEncode(strSplitted(2)) & " har kickats ut ur chatten av " & Server.HTMLEncode(strSplitted(3)) & " (" &
strSplitted(0) & ")]</font>" & vbCrLf & vbCrLf
Else 'Privat meddelande
If LCase(strSplitted(1)) = LCase(Session("Name")) Then
strText = Server.HTMLEncode(Mid(strSplitted(3), 9 + Len(strSplitted(1)), Len(strSplitted(3))))
ParseText = "<font color=""#ff0000""><b>" & Server.HTMLEncode(strSplitted(2)) & "</b> - (" &
strSplitted(0) & "):</table></font>" & CheckForLinks(strText) & "" & vbCrLf & vbCrLf
ElseIf LCase(strSplitted(2)) = LCase(Session("Name")) Then
strText = Server.HTMLEncode(Mid(strSplitted(3), 9 + Len(strSplitted(1)), Len(strSplitted(3))))
ParseText = "<font color=""#0000ff""><b>Skickat till " & Server.HTMLEncode(strSplitted(1)) & "</b> -
(" & strSplitted(0) & "):</font>" & CheckForLinks(strText) & "" & vbCrLf & vbCrLf
End If
End If
End Function
Function IsOnline(strUser) 'Kolla om en användare är online just nu...
Application.Lock
online = Application("Online")
online = Split(online, vbCrLf)
For Each line In online
If Len(line) < 2 Then Exit For
line = Split(line, "|")
If LCase(line(0)) = LCase(Session("Name")) Then
IsOnline = "True"
Exit For
End If
Next
Application.Unlock
End Function
%>
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<style type="text/css">
body {
scrollbar-base-color: #FFE784;
scrollbar-arrow-color: #000000;
scrollbar-highlight-color: #;
scrollbar-3dlight-color: #000000;
scrollbar-darkshadow-color: #000000;
scrollbar-track-color: #FFF7EF }
</style>
<title>Chat rum</title>
<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
<style type="text/css">
body {font-family: Verdana, Helvetica, sans-serif; font-size: 10px; background-color: #ffffff}
td {font-family: Verdana, Helvetica, sans-serif; font-size: 10px}
a {font-family: Verdana, Helvetica, sans-serif; font-size: 10px; color: #aa9d71; text-decoration: none}
a:hover {font-family: Verdana, Helvetica, sans-serif; font-size: 10px; color: #145285}
#textbox {font-family: Verdana, Helvetica, sans-serif; font-size: 10px}
.blacklink {color: #000000; text-decoration: underline}
.boxen {border: 1px #000000 solid; font-size: 5; background-color: #F1F1F1}
</style>
<script language="JavaScript">
<!-- ;
function refresh() {
location.href = "room.asp?refreshrate=<%=Request("refreshrate")%>";
}
// end hide -->
</script>
</head>
<body bgcolor="#FFF7EF" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"
onload="javascript:setTimeout('refresh()',<%=Request("refreshrate")%> );">
<%
Set fileObject = Server.CreateObject("Scripting.FileSystemObject")
CheckFile
Set inStream = fileObject.OpenTextFile(Server.MapPath("" & Date & ".txt"), 1, True, False)
rawfile = inStream.ReadAll
splittedFile = Split(rawfile, vbCrLf)
For Each thisLine in splittedFile
If Len(thisLine) <= 3 Then Exit For
If DateDiff("s", DateAdd("s", 0, Left(thisLine, 19)), Now) => 120 Then Exit For '120 sekunder = 2 minuter
file = file & vbCrLf & ParseText(thisLine)
Next
inStream.Close
Set inStream = Nothing
If IsOnline(Session("Name")) = "True" Then
strText = Request.Form("lastmessage")
If strText <> "" And Session("lastmessage") <> strText Then
Session("lastmessage") = strText
If LCase(Left(strText, 6)) = "/msg " & chr(34) Then
strTo = Mid(strText, 7, Instr(7, strText, Chr(34)) - 7)
Else
strTo = "public"
End If
file = ParseText(Now & "|" & strTo & "|" & Session("Name") & "|" & strText) & file
rawfile = Now & "|" & strTo & "|" & Session("Name") & "|" & strText & vbCrLf & rawfile
Set outStream = fileObject.CreateTextFile(Server.MapPath("" & Date & ".txt"), True)
outStream.WriteLine(rawfile)
outStream.Close
Set outStream = Nothing
End If
Else
Session("Name") = ""
Session("Admin") = ""
Session("lastmessage") = ""
'Vill inte ta bort Pelle´s egna sessioner så tömmer bara mina egna...
%>
<script language="JavaScript">
<!-- ;
parent.location.href = "chatlogin.asp?error=not_logged_in";
// end hide -->
</script>
<%
End If
If DateDiff("s", Time, "23:59:59") <= 120 Then
file = "<font color=""#ff0000""><b>[Om " & DateDiff("s", Time, "23:59:59") + 1 & " sekund(er) byts chat-filen
ut]</b></font>" & vbCrLf & file
End If
Response.Write file
%>
</body>
</html>
Du har en funktion i en funktion, det går ju inte. Flytta ut Free() utanför den första funktionen.
AampyMedlem sedan feb. 20011 498 inlägg LilleSkutt: Jag gjorde som du skrev men nu när jag skriver
så kommer det ingen bild, det skrivs ut på det vanliga sättet.
@ndersMedlem sedan juni 200032 967 inläggJag kan inte se att du kallar på funktionen någon gång?
AampyMedlem sedan feb. 20011 498 inlägg Hur kallar man på funktionen då?
JjorgenMedlem sedan feb. 20012 412 inlägg Response.write "<p> "& Free(RS("MyField")) &"</p> "
AampyMedlem sedan feb. 20011 498 inlägg Vart ska jag lägga in den koden jorgen, jag har laddat ner denna kod jag skrev innan så det är inte jag som har gjort den. Hoppas ni kan visa mig 
JjorgenMedlem sedan feb. 20012 412 inlägg Vilken del av koden skriver ut : ) i din kod?
AampyMedlem sedan feb. 20011 498 inlägg Den här delen:
<%
If strSplitted(1) = "public" Then 'Meddelande till alla
ParseText = "<td width='600' bgcolor='#FFEFCE'><b><font color='#000080'>" & strSplitted(2) &
"</font></b><i><font color='#999999'> - (" & strSplitted(0) & ")</i></font>: " &
CheckForLinks(Server.HTMLEncode(strSplitted(3))) & "</td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionlogin" Then 'Nån har loggat in
ParseText = "<tr><td width='600' bgcolor='#FFE784'><b><font color=""#000000"">" &
Server.HTMLEncode(strSplitted(2)) & " stiger in i chatten (" & strSplitted(0) & ")</b></font></td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionlogoff" Then 'Nån har loggat ut
ParseText = "<tr><td width='600' bgcolor='#FFE784'><b><font color=""#000000"">" &
Server.HTMLEncode(strSplitted(2)) & " har lämnat chatten (" & strSplitted(0) & ")</font></b></td></tr>" & vbCrLf & vbCrLf
ElseIf strSplitted(1) = "actionkicked" Then 'Nån har kickats ut ur chatten av en administratör
ParseText = "<tr><td width='600' bgcolor='#FFE784'><font color=""#aaaaaa"">[" &
Server.HTMLEncode(strSplitted(2)) & " har kickats ut ur chatten av " & Server.HTMLEncode(strSplitted(3)) & " (" &
strSplitted(0) & ")]</font>" & vbCrLf & vbCrLf
Else 'Privat meddelande
If LCase(strSplitted(1)) = LCase(Session("Name")) Then
strText = Server.HTMLEncode(Mid(strSplitted(3), 9 + Len(strSplitted(1)), Len(strSplitted(3))))
ParseText = "<tr><td width='600' bgcolor='#FFE784'><font color=""#ff0000""><b>" &
Server.HTMLEncode(strSplitted(2)) & "</b> - (" & strSplitted(0) & "): </font>" & CheckForLinks(strText) & "</td></tr>" &
vbCrLf & vbCrLf
ElseIf LCase(strSplitted(2)) = LCase(Session("Name")) Then
strText = Server.HTMLEncode(Mid(strSplitted(3), 9 + Len(strSplitted(1)), Len(strSplitted(3))))
ParseText = "<tr><td width='600' bgcolor='#FFE784'><font color=""#0000ff""><b>Skickat till " &
Server.HTMLEncode(strSplitted(1)) & "</b> - (" & strSplitted(0) & "):</font>" & CheckForLinks(strText) & "</td></tr></table>"
& vbCrLf & vbCrLf
End If
End If
JjorgenMedlem sedan feb. 20012 412 inlägg Hoppas jag gissat rätt i din kod nu. Om det är CheckForLinks(strText) som skriver ut meddelandet, bytar du till:
" & CheckForLinks(Free(strText)) & "
AampyMedlem sedan feb. 20011 498 inlägg Tack så mycket jorgen, det funkar nu 