Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 ChkMail adds space to message
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

ajhvdb
Junior Member

Netherlands
392 Posts

Posted - 29 October 2002 :  20:06:37  Show Profile
While using function "formatstr" for something else found out that the called function "chkmail" adds a space to the beginning of the message. At least with our forum code.

I've changed it from:
function ChkMail(ByVal strToFormat)
	Dim strArray
	Dim Counter
	
	if InStr(1, strToFormat, " ") > 0 Then
	
		strArray = Split(Replace(strToFormat, "<br />", " <br />", 1, -1, vbTextCompare), " ", -1)
		'ChkMail = strArray(0)

		for Counter = 0 to UBound(strArray)
			If (InStr(strArray(Counter), "@") > 0) and _
			not(InStr(UCase(strArray(Counter)), "MAILTO:") > 0) and _
			not(InStr(UCase(strArray(Counter)), "FTP:") > 0) and _
			not(InStr(UCase(strArray(Counter)), "[URL") > 0) then
				ChkMail = ChkMail & " " & edit_hrefs(strArray(counter), 4)
			else
				ChkMail = ChkMail & " " & strArray(counter)
			end if
		next
		ChkMail = Replace(ChkMail, " <br />", "<br />", 1, -1, vbTextCompare)
	else
		if (InStr(strToFormat, "@") > 0) and _
		not(InStr(UCase(strToFormat), "MAILTO:") > 0) and _
		not(InStr(UCase(strToFormat), "FTP:") > 0) and _
		not(InStr(UCase(strToFormat), "[URL") > 0) then
			ChkMail = ChkMail & " " & edit_hrefs(strToFormat, 4)
		else
			ChkMail = strToFormat
		end if
	end if
end function


To:

function ChkMail(ByVal strToFormat)
	Dim strArray
	Dim Counter
	Dim strSpace
	strSpace = ""
	
	if InStr(1, strToFormat, "@") > 0 Then
		if InStr(1, strToFormat, " ") > 0 Then
	
			strArray = Split(Replace(strToFormat, "<br />", " <br />", 1, -1, vbTextCompare), " ", -1)
			'ChkMail = strArray(0)

			for Counter = 0 to UBound(strArray)
				If (InStr(strArray(Counter), "@") > 0) and _
				not(InStr(UCase(strArray(Counter)), "MAILTO:") > 0) and _
				not(InStr(UCase(strArray(Counter)), "FTP:") > 0) and _
				not(InStr(UCase(strArray(Counter)), "[URL") > 0) then
					ChkMail = ChkMail & strSpace & edit_hrefs(strArray(counter), 4)
					strSpace = " "
				else
					ChkMail = ChkMail & strSpace & strArray(counter)
					strSpace = " "
				end if
			next
			ChkMail = Replace(ChkMail, " <br />", "<br />", 1, -1, vbTextCompare)
		else
			if (InStr(strToFormat, "@") > 0) and _
			not(InStr(UCase(strToFormat), "MAILTO:") > 0) and _
			not(InStr(UCase(strToFormat), "FTP:") > 0) and _
			not(InStr(UCase(strToFormat), "[URL") > 0) then
				ChkMail = ChkMail & strSpace & edit_hrefs(strToFormat, 4)
				strSpace = " "
			else
				ChkMail = strToFormat
			end if
		end if
	else
		ChkMail = strToFormat
	end if
end function

ajhvdb
Junior Member

Netherlands
392 Posts

Posted - 02 November 2002 :  11:28:33  Show Profile
It would have been nice if the moderator who moved this topic from the forum "Bug" to "General" replied with a message why it's not a Bug. I'm I wrong, right or just being ignored...
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 02 November 2002 :  11:56:01  Show Profile
it adds a space for a reason. If the space wasn't added and you have an e-mail address as the first item in the message, it's not recognized as an e-mail address.
Go to Top of Page

ajhvdb
Junior Member

Netherlands
392 Posts

Posted - 02 November 2002 :  15:22:13  Show Profile
Thank for the quick answer, will check this out.
The added if:
	if InStr(1, strToFormat, "@") > 0 Then

does help to speed up the display of your pages though (depending on message lengths twice as fast) because vb doesn't have to create a big array if no email @ is found

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07