Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Thread Demo

  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thread Demo

    if i design forum site and need the user to link to new threads by it's demo not the title, i have to take 5 words from the newest thread then link it to the complete thread, for example my thread will be like this:

    if idesign forum site...

    i think i have to coonvert string to array thin count spaces then cut and print the result but how by the code??
    Last edited by ahmedsoliman; 01-26-2003 at 01:59 PM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Instead of going by number of words, if you don't want your table to get out of whack assuming someone might type in a bunch of letters in a row, I'd use something like this:

    Code:
    <%
    Function PreviewString(byVal str)
       Dim strarray, joinLen, psRegEx, newstr, maxlen, spaceexists
       ' Change the maxlength (maxlen) below into something more feasible, this is for example.
       maxlen = 50
       Set psRegEx = New RegExp
       psRegEx.Pattern = "\s+"
       psRegEx.Global = True
       newstr = Join(Split(psRegEx.Replace(Trim(Replace(str,vbCrLf," "))," ")," ")," ")
       spaceexists = (InStrRev(newstr," ",maxlen)-1 > -1)
       If spaceexists = True Then
          PreviewString = Left(newstr,InStrRev(newstr," ",maxlen)-1) & "..."
       Else
          PreviewString = Left(newstr,maxlen) & "..."
       End If
    End Function
    
    MyString = "This is a test of the Emergency Broadcast System. The broadcasters of your area in voluntary cooperation with the Federal, State and local authorities have developed this system to keep you informed in the event of an emergency. If this had been an actual emergency, (optional -- stations may mention the types of emergencies likely to occur in their area) the Attention Signal you just heard would have been followed by official information, news or instructions. This station (optional -- insert station call sign) serves the (operational area name) area. This concludes this test of the Emergency Broadcast System."
    MyBadString = "ZZZZZZZZZZZZZZzzzzzzzzzzzzzzzzzzzzzzzzzzZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZzzzzzzzzzZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
    %>
    
    <% = PreviewString(MyString) %><br />
    <% = PreviewString(MyBadString) %>
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks whammy but i designed code right now and it works.
    <%
    str=" hi evrey body, i am ahmed soliman"
    strlen=len(str)

    while spacecount=5 or i=strlen
    i=i+1

    strtrain=mid(str,i,1)
    demotext=demotext&strtrain
    if strtrain=" " then
    spacecount=spacecount+1
    end if

    wend
    dot="..."
    demotext=demotext&dot
    Response.Write(demotext)
    Response.Write("<br>")

    %>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •