---
title: ":) ska bli en bild"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/13343-ska-bli-en-bild"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "ampy"
published: "2001-12-23T22:28:00.000Z"
updated: "2001-12-24T11:16:00.000Z"
replies: 15
views: 276
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/asp/13343-ska-bli-en-bild"
---

# :) ska bli en bild

## #1 — ampy, 2001-12-23T22:28Z

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?

Permalänk: https://www.webforum.nu/p/13343

## #2 — jorgen, 2001-12-23T22:42Z

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 :)

Permalänk: https://www.webforum.nu/p/301532

## #3 — ampy, 2001-12-23T22:48Z

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)
```

Permalänk: https://www.webforum.nu/p/301533

## #4 — jorgen, 2001-12-23T22:55Z

Hur ser din kod ut?

Permalänk: https://www.webforum.nu/p/301534

## #5 — ampy, 2001-12-23T22:56Z

```
<!--#include file="functions.inc.asp"-->
<%

Function ParseText(strText) 'Skriver man en pipe &#0124; i texten så kommer allt efter pipen att försvinna från meddelandet!
	strSplitted = Split(strText, "&#0124;")

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, "&#0124;")
		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 & "&#0124;" & strTo & "&#0124;" & Session("Name") & "&#0124;" & strText) & file
		rawfile = Now & "&#0124;" & strTo & "&#0124;" & Session("Name") & "&#0124;" & 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>
```

Permalänk: https://www.webforum.nu/p/301535

## #6 — jorgen, 2001-12-23T23:01Z

Hur anropar du den då?

Permalänk: https://www.webforum.nu/p/301536

## #7 — LilleSkutt, 2001-12-23T23:01Z

Du har en funktion i en funktion, det går ju inte. Flytta ut Free() utanför den första funktionen.

Permalänk: https://www.webforum.nu/p/301537

## #8 — ampy, 2001-12-23T23:06Z

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.

Permalänk: https://www.webforum.nu/p/301538

## #9 — @nders, 2001-12-24T10:43Z

Jag kan inte se att du kallar på funktionen någon gång?

Permalänk: https://www.webforum.nu/p/301539

## #10 — ampy, 2001-12-24T10:46Z

Hur kallar man på funktionen då?

Permalänk: https://www.webforum.nu/p/301540

## #11 — jorgen, 2001-12-24T10:52Z

```
Response.write "<p> "& Free(RS("MyField")) &"</p> "
```

Permalänk: https://www.webforum.nu/p/301541

## #12 — ampy, 2001-12-24T10:59Z

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 :)

Permalänk: https://www.webforum.nu/p/301542

## #13 — jorgen, 2001-12-24T11:01Z

Vilken del av koden skriver ut : ) i din kod?

Permalänk: https://www.webforum.nu/p/301543

## #14 — ampy, 2001-12-24T11:02Z

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
```

Permalänk: https://www.webforum.nu/p/301544

## #15 — jorgen, 2001-12-24T11:07Z

Hoppas jag gissat rätt i din kod nu. Om det är **CheckForLinks(strText)** som skriver ut meddelandet, bytar du till:

```
" & CheckForLinks(Free(strText)) & "
```

Permalänk: https://www.webforum.nu/p/301545

## #16 — ampy, 2001-12-24T11:16Z

Tack så mycket jorgen, det funkar nu :)

Permalänk: https://www.webforum.nu/p/301546

---

Tråden på webben: https://www.webforum.nu/amne/asp/13343-ska-bli-en-bild
