word wrap

Discussion in 'ASP General' started by news.pandora.be, May 17, 2004.

  1. I want to display a string in a table but when a word in the string is
    longer then 40 letters it won't wrap. Does anyone know how I can fix this ?

    Thanx

    Wannes
     
    news.pandora.be, May 17, 2004
    #1
    1. Advertising

  2. And how would I have te do that ?

    "Curt_C [MVP]" <software_AT_darkfalz.com> schreef in bericht
    news:...
    > where would you expect it to wrap? if it's a single, uninterrupted, string
    > of characters the browser has no idea where to break it, besides it's not
    > right to break it most likely. You'll have to build a custom string reader
    > to insert a "<br>" or linebreak (if displayed in a textbox, etc).
    >
    > --
    > Curt Christianson
    > Owner/Lead Developer, DF-Software
    > Site: http://www.Darkfalz.com
    > Blog: http://blog.Darkfalz.com
    >
    >
    > "news.pandora.be" <> wrote in message
    > news:ed7qc.113060$-ops.be...
    > > I want to display a string in a table but when a word in the string is
    > > longer then 40 letters it won't wrap. Does anyone know how I can fix

    this
    > ?
    > >
    > > Thanx
    > >
    > > Wannes
    > >
    > >

    >
    >
     
    news.pandora.be, May 17, 2004
    #2
    1. Advertising

  3. What kind of word is longer than 40 letters? Where would it make sense to
    break up such a word? Exactly in half, after 20 characters, after 32
    characters, 5 characters from the end, ...?

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/





    "news.pandora.be" <> wrote in message
    news:ed7qc.113060$-ops.be...
    >I want to display a string in a table but when a word in the string is
    > longer then 40 letters it won't wrap. Does anyone know how I can fix this
    > ?
    >
    > Thanx
    >
    > Wannes
    >
    >
     
    Aaron Bertrand [MVP], May 17, 2004
    #3
  4. It's in a sort of message board so I cant realy controle what will be
    displayed in the table.
    I have to make shure that if someone has put in such long words my table
    will still be displayed as it should.
    Therefor I'm looking for an ASP-code that places an "<BR>" into my string if
    there are words longer than 40 letters in it. It doesn't realy matter to me
    where the words are broken as long as they are.

    gr.

    Wannes

    "Aaron Bertrand [MVP]" <> schreef in bericht
    news:...
    > What kind of word is longer than 40 letters? Where would it make sense to
    > break up such a word? Exactly in half, after 20 characters, after 32
    > characters, 5 characters from the end, ...?
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > http://www.aspfaq.com/
    >
    >
    >
    >
    >
    > "news.pandora.be" <> wrote in message
    > news:ed7qc.113060$-ops.be...
    > >I want to display a string in a table but when a word in the string is
    > > longer then 40 letters it won't wrap. Does anyone know how I can fix

    this
    > > ?
    > >
    > > Thanx
    > >
    > > Wannes
    > >
    > >

    >
    >
     
    news.pandora.be, May 17, 2004
    #4
  5. I would do something like this when you STORE the data (then you don't have
    to do it every time you display it).

    data = request.form("data")
    datas = split(data, " ")
    for i = 0 to ubound(datas)
    if len(datas(i))>40 then
    tmp = ""
    for i = 1 to len(datas(i)) step 40
    tmp = tmp & "<br>" & mid(str, i, 40)
    next
    datas(i) = tmp
    end if
    next
    data = join(datas, " ")
    ' now replace single apostrophes with two, insert into db, etc.

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/





    "news.pandora.be" <> wrote in message
    news:SJ7qc.113124$-ops.be...
    > It's in a sort of message board so I cant realy controle what will be
    > displayed in the table.
    > I have to make shure that if someone has put in such long words my table
    > will still be displayed as it should.
    > Therefor I'm looking for an ASP-code that places an "<BR>" into my string
    > if
    > there are words longer than 40 letters in it. It doesn't realy matter to
    > me
    > where the words are broken as long as they are.
    >
    > gr.
    >
    > Wannes
    >
    > "Aaron Bertrand [MVP]" <> schreef in bericht
    > news:...
    >> What kind of word is longer than 40 letters? Where would it make sense
    >> to
    >> break up such a word? Exactly in half, after 20 characters, after 32
    >> characters, 5 characters from the end, ...?
    >>
    >> --
    >> Aaron Bertrand
    >> SQL Server MVP
    >> http://www.aspfaq.com/
    >>
    >>
    >>
    >>
    >>
    >> "news.pandora.be" <> wrote in message
    >> news:ed7qc.113060$-ops.be...
    >> >I want to display a string in a table but when a word in the string is
    >> > longer then 40 letters it won't wrap. Does anyone know how I can fix

    > this
    >> > ?
    >> >
    >> > Thanx
    >> >
    >> > Wannes
    >> >
    >> >

    >>
    >>

    >
    >
     
    Aaron Bertrand [MVP], May 17, 2004
    #5
  6. > tmp = tmp & "<br>" & mid(str, i, 40)

    OOPS! Change str to datas(i) here.
     
    Aaron Bertrand [MVP], May 17, 2004
    #6
  7. news.pandora.be

    Jeff Cochran Guest

    On Mon, 17 May 2004 18:20:47 GMT, "news.pandora.be" <> wrote:

    >And how would I have te do that ?


    Something Like:

    NewString = ""
    StringLength = Len(WordString)
    For i = 1 to (StringLength/40)
    NewString = NewString & Left(WordString,40) & "<br>" & VbCrLf
    StringLength = StringLength - 40
    WordString = Right(WordString,StringLength)
    Next
    Response.Write NewString

    Note, this isn't tested and it only breaks the string into 40
    character lines, doesn't break on words or spaces.

    But there's probably a WordWrap function floating around that
    someone's already written. Hang on...

    Yep. Google finds your answer:

    http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=4&txtCodeId=6220

    Jeff



    >
    >"Curt_C [MVP]" <software_AT_darkfalz.com> schreef in bericht
    >news:...
    >> where would you expect it to wrap? if it's a single, uninterrupted, string
    >> of characters the browser has no idea where to break it, besides it's not
    >> right to break it most likely. You'll have to build a custom string reader
    >> to insert a "<br>" or linebreak (if displayed in a textbox, etc).
    >>
    >> --
    >> Curt Christianson
    >> Owner/Lead Developer, DF-Software
    >> Site: http://www.Darkfalz.com
    >> Blog: http://blog.Darkfalz.com
    >>
    >>
    >> "news.pandora.be" <> wrote in message
    >> news:ed7qc.113060$-ops.be...
    >> > I want to display a string in a table but when a word in the string is
    >> > longer then 40 letters it won't wrap. Does anyone know how I can fix

    >this
    >> ?
    >> >
    >> > Thanx
    >> >
    >> > Wannes
    >> >
    >> >

    >>
    >>

    >
     
    Jeff Cochran, May 17, 2004
    #7
  8. news.pandora.be

    Evertjan. Guest

    news.pandora.be wrote on 17 mei 2004 in
    microsoft.public.inetserver.asp.general:

    > It's in a sort of message board so I cant realy controle what will be
    > displayed in the table.
    > I have to make shure that if someone has put in such long words my
    > table will still be displayed as it should.
    > Therefor I'm looking for an ASP-code that places an "<BR>" into my
    > string if there are words longer than 40 letters in it. It doesn't
    > realy matter to me where the words are broken as long as they are.
    >


    this simple j(ava)script script breaks all words
    longer than 40 chars long into 40 char parts
    ended by a - and a space:

    t = t.replace(/(\S{40})/g,"$1- ")


    ======================

    same in vbscript [longer]:

    Set regEx = New RegExp
    regEx.Pattern = "(\S{40})"
    regEx.Global = True
    t = regEx.Replace(t, "$1- ")




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., May 17, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Coyne  Gaijin42

    Word wrap line break code and algorithm for c#

    Jason Coyne Gaijin42, Apr 8, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    24,265
    Jason Coyne Gaijin42
    Apr 8, 2004
  2. Mark A. Sam

    Content Holder and word wrap

    Mark A. Sam, Mar 28, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    406
    Mark A. Sam
    Mar 28, 2006
  3. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    717
    Chronic Philharmonic
    May 10, 2008
  4. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    254
    Art Werschulz
    Sep 22, 2003
  5. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    257
    Anno Siegel
    Sep 25, 2003
Loading...

Share This Page