Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   word wrap (http://www.velocityreviews.com/forums/t794478-word-wrap.html)

news.pandora.be 05-17-2004 06:09 PM

word wrap
 
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 05-17-2004 06:20 PM

Re: word wrap
 
And how would I have te do that ?

"Curt_C [MVP]" <software_AT_darkfalz.com> schreef in bericht
news:eGMCDrDPEHA.3476@TK2MSFTNGP09.phx.gbl...
> 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" <no@no.com> wrote in message
> news:ed7qc.113060$f83.6457443@phobos.telenet-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] 05-17-2004 06:32 PM

Re: word wrap
 
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" <no@no.com> wrote in message
news:ed7qc.113060$f83.6457443@phobos.telenet-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 05-17-2004 06:44 PM

Re: word wrap
 
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]" <aaron@TRASHaspfaq.com> schreef in bericht
news:O6j8V1DPEHA.1048@tk2msftngp13.phx.gbl...
> 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" <no@no.com> wrote in message
> news:ed7qc.113060$f83.6457443@phobos.telenet-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] 05-17-2004 06:59 PM

Re: word wrap
 
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" <no@no.com> wrote in message
news:SJ7qc.113124$Ug7.6291513@phobos.telenet-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]" <aaron@TRASHaspfaq.com> schreef in bericht
> news:O6j8V1DPEHA.1048@tk2msftngp13.phx.gbl...
>> 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" <no@no.com> wrote in message
>> news:ed7qc.113060$f83.6457443@phobos.telenet-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] 05-17-2004 07:04 PM

Re: word wrap
 
> tmp = tmp & "<br>" & mid(str, i, 40)

OOPS! Change str to datas(i) here.



Jeff Cochran 05-17-2004 07:11 PM

Re: word wrap
 
On Mon, 17 May 2004 18:20:47 GMT, "news.pandora.be" <no@no.com> 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...txtCodeId=6220

Jeff



>
>"Curt_C [MVP]" <software_AT_darkfalz.com> schreef in bericht
>news:eGMCDrDPEHA.3476@TK2MSFTNGP09.phx.gbl...
>> 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" <no@no.com> wrote in message
>> news:ed7qc.113060$f83.6457443@phobos.telenet-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
>> >
>> >

>>
>>

>



Evertjan. 05-17-2004 07:29 PM

Re: word wrap
 
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)


All times are GMT. The time now is 01:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.