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 MOD-Group
 MOD Add-On Forum (W/O Code)
 Split thread feature.
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 5

Etymon
Advanced Member

United States
2385 Posts

Posted - 01 November 2004 :  11:32:50  Show Profile  Visit Etymon's Homepage
quote:
Originally posted by Davio

Ok, for those of you who offered to help me out with the mod, this one's for you.

I want to display only 150 characters of a message. Anything after that is cut off and replaced with an elipses ...

Needs to be in vbscript. And if possible (not a must, but would be good) to not cut off the message in the middle of a word. But cut it off at the nearest space.

Thanks guys.



Hi Davio,

Take a look at http://forum.snitz.com/forum/topic.asp?ARCHIVE=true&TOPIC_ID=26734&SearchTerms=rsNewStuff, and look for RichardKinsers remarks about rsNewStuff. That's his code for ... - I use it often, and it works fine.

Look for:

TopicSubject = TopicSubject & Trim(Left(ChkString(rsNewStuff("T_SUBJECT"),"display"),16)) & "...."

You can change the T_SUBJECT to fit your field and the 16 to 150 to fit your length.

Etymon
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 01 November 2004 :  16:02:29  Show Profile
Thanks Etymon and Stimmy.
Will try out the code.

Support Snitz Forums
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 07 November 2004 :  12:11:59  Show Profile
I found the second mod which works together with the one above. If you want to take a look at the code, get it here:

Threaded Mod
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 11 November 2004 :  10:55:20  Show Profile

Davio, I just checked your site for progress and you haven't updated it in a while. So you may have solved this by now
Gremlin posted a function to strip html to help limit characters for the "simple Slash Mod". I don't know what the final version looked like you might want to give it a look.
I've been using it to help limit characters on a personal weblog that I made from a snitz forum.
It works fine but I've never put it through any real serious testing

Here's the function (Add the tags you want to remove to "TAGLIST")

Function RemoveHTML( strText )
  Dim TAGLIST
  TAGLIST=";A;a;B;b;font;IMG;img;CENTER;center;PRE;pre;BR;br;"
    
  Dim nPos1
  Dim nPos2
  Dim nPos3
  Dim strResult
  Dim strTagName
  Dim bRemove
  Dim bSearchForBlock
  
  nPos1 = InStr(strText, "<")
  Do While nPos1 > 0
    nPos2 = InStr(nPos1 + 1, strText, ">")
    If nPos2 > 0 Then
      strTagName = Mid(strText, nPos1 + 1, nPos2 - nPos1 - 1)
      strTagName = Replace(Replace(strTagName, vbCr, " "), vbLf, " ")
      nPos3 = InStr(strTagName, " ")
      If nPos3 > 0 Then
        strTagName = Left(strTagName, nPos3 - 1)
      End If
         
      If Left(strTagName, 1) = "/" Then
        strTagName = Mid(strTagName, 2)
        bSearchForBlock = False
      Else
        bSearchForBlock = True
      End If
           
      If InStr(1, TAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
        bRemove = True
        
        If bSearchForBlock Then
        
          If InStr(1, BLOCKTAGLIST, ";" & strTagName & ";", vbTextCompare) > 0 Then
            nPos2 = Len(strText)
            nPos3 = InStr(nPos1 + 1, strText, "</" & strTagName, vbTextCompare)
        
            If nPos3 > 0 Then
              nPos3 = InStr(nPos3 + 1, strText, ">")
            End If
                      
            If nPos3 > 0 Then
              nPos2 = nPos3
            End If
            
          End If
          
        End If
        
      Else
        bRemove = False
      End If
          
      If bRemove Then
        strResult = strResult & Left(strText, nPos1 - 1)
        strText = Mid(strText, nPos2 + 1)
      Else
        strResult = strResult & Left(strText, nPos1)
        strText = Mid(strText, nPos1 + 1)
      End If
    Else
      strResult = strResult & strText
      strText = ""
    End If
      
    nPos1 = InStr(strText, "<")
  Loop
  strResult = strResult & strText    
  RemoveHTML = strResult
End Function


I use it like this

dim sChar, tChar, hChar, dChar, aChar 
sChar = 100 ' number of characters to show 
tChar = Len(formatStr(ChkString(rs("T_MESSAGE"),"sqlString"))) 'number of characters in message
hChar = Len(RemoveHtml(formatStr(ChkString(rs("T_MESSAGE"),"sqlString")))) 'number of characters with out html tags
dChar = tChar - hChar 'adjust factor 
aChar = sChar + dChar 'adjusted character count

And then...
Response.Write formatStr(Left(rs("T_MESSAGE"),aChar)) & "  ...."



Also like I said in an earlier post, I've been working on a mod for this and I believe it's working pretty good.
It looks similar to Davios. I'm not going to release it as a mod because Davios will probably be alot nicer (my coding abilities are very limited ) and I had never seen something like this, so I wasn't sure how it should work.
It's a stand alone mod (1 file and a link) and if anybody wants to look at it, I will email just ask.


    _-/Cripto9t\-_

Edited by - cripto9t on 11 November 2004 10:56:40
Go to Top of Page

cripto9t
Average Member

USA
881 Posts

Posted - 11 November 2004 :  11:01:15  Show Profile
quote:
Originally posted by Carefree

I found the second mod which works together with the one above. If you want to take a look at the code, get it here:

Threaded Mod


Thanks Carefree . I've seen this mod by Babygate asked for a few times but never found a working link.
I'm going to try this out.

    _-/Cripto9t\-_
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 11 November 2004 :  11:59:12  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
This topic is a perfect example of a topic that needs to be split....

-Stim
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 11 November 2004 :  16:37:35  Show Profile
I'll keep that function in mind cripto, in case Da_Stim function doesn't work out for me.

I only get to work on it on weekends. But the mod is going fine. As I mentioned at my site, the visual part is done. Just need to finish up on the coding.

Support Snitz Forums
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 11 November 2004 :  18:31:51  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Davio, updated that function to include HTML support....


Function left150(fString)
  if ((InStr(fString, "<")>0) and (InStr(fString, ">")>0) and len(fString)>150) Then
    Dim strTemp, strTempcnt, strBrk1, strBrk2, strRemoved,tagCount
	strTemp = fString
	strTempcnt = 0
	strRemoved = 0
	tagCount = 0
	  Do While (InStr(1, strTemp, "<")>0) And (InStr(1, strTemp, ">")>0)
	    strBrk1 = InStr(1, strTemp, "<")
	    strBrk2 = InStr(1, strTemp, ">")-strBrk1
	    tagCount = tagCount + 1
	    strRemoved = strRemoved + Len(Mid(strTemp, strBrk1, strBrk2))
	    strTemp = Left(strTemp, Instr(1, strTemp, "<")-1) & Right(strTemp, Len(strTemp)-Instr(1,strTemp, ">"))
	    strTempcnt =  Len(strTemp)
		if (InStr(Left(strTemp, 150), "<")<1) And (InStr(Left(StrTemp,150),">")<1) then
		  Exit Do
		end if
	  Loop
	  
	  if ((strTempcnt > 150) and (strRemoved > 0)) then
		LastChars = Right(Left(strTemp, (140+Cint(Instr(Mid(strTemp,140,15)," ")))-1),5)
		left150 = Left(fString, InStr(fString, LastChars)+4) & "..."
	  elseif (strTempcnt > 150) and (strRemoved < 1) then 
 	    left150 = Left(fString, (140+Cint(Instr(Mid(fString,140,15)," ")))-1) & "..."
	  else
	    left150 = fString
	  end if
  elseif len(fString)>150 then
 	left150 = Left(fString, (140+Cint(Instr(Mid(fString,140,15)," ")))-1) & "..."
  else
        left150 = fString
  end if
End Function

-Stim

Edited by - Da_Stimulator on 14 November 2004 21:53:17
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 11 November 2004 :  18:35:00  Show Profile
Cool stuff Stim. Will let you know if it works.

Support Snitz Forums
Go to Top of Page

aspwiz
Junior Member

250 Posts

Posted - 13 November 2004 :  05:04:37  Show Profile  Visit aspwiz's Homepage
Hey davio....

Any chance I can get the code for this so far so i can convert it to speedball II ?
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 13 November 2004 :  08:16:08  Show Profile
Everyone will get it when it's done aspwiz.

Support Snitz Forums
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 14 November 2004 :  19:54:20  Show Profile
Hey Stim, tried your function, but not extensively. One thing I notice is, the ellipses ... is added to the post, even when it is less than 150 characters. The ellipses should only be added when the post has been cut short. But if it is the full post, then no ellipses.

Support Snitz Forums
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 14 November 2004 :  21:54:10  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
Updated it davio, give her a try now :)

-Stim
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 15 November 2004 :  01:10:38  Show Profile
That works Stim. That works.

Support Snitz Forums
Go to Top of Page

Da_Stimulator
DEV Team Forum Moderator

USA
3373 Posts

Posted - 15 November 2004 :  01:14:17  Show Profile  Send Da_Stimulator an AOL message  Send Da_Stimulator a Yahoo! Message
I get first dibs when ur done :P

-Stim
Go to Top of Page
Page: of 5 Previous Topic Topic Next Topic  
Previous Page | Next Page
 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