Perhaps there is a script at www.cflib.org that would help? I've grabbed
some great scripts from there in the past.

Peter Tilbrook
Director, ColdGen Internet Solutions
Manager, ACT and Region ColdFusion Users Group
Director of Technology, Global Information Exchange
4/73 Tharwa Road
Queanbeyan, NSW, 2620
AUSTRALIA

     WWW 1: http://www.coldgen.com/
     WWW 2: http://www.actcfug.com/
Telephone: +61-2-6284-2727
   E-mail: [EMAIL PROTECTED]

>>

All of my external emails are scanned for viruses using the latest available
Norton AV signatures. Also I do NOT maintain an Address book or Contact list
to minimise the risk of infecting recipients of my messages for viruses. I
also prefer "plain text" emails for speed and efficiency.

Powered by Lookout:

Lookout is lightning-fast search for your email, files, and desktop works
with Microsoft Outlook.

http://www.lookoutsoft.com/Lookout/

>> 
 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis
Sent: Saturday, 29 January 2005 2:55 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Inserting line breaks after so many charachters

There was a regular expression posted to do this anyway ages ago Will just
have to find it

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Johanna
Sherry
Sent: Saturday, January 29, 2005 2:51 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Inserting line breaks after so many charachters


At first glance it looks like Steve's suggestion would break after 50 words
not 50 characters, and Grant's suggestion doesn't take into account whether
the 50th character would break a word.
I would go with Phil's suggestion but process each chunk separately. It's
slower but more accurate (depends on what is more important to you) I.e. 
Get the first 50 characters, replace the last space with <br>, then add
whatever came after that space back onto the remaining string and take the
next 50, repeat. 

Something like:

<cfset testString = "This will break your text up into lines of no more than
50 chars per line. The quick brown fox jumps over the lazy dog. The quick
brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy
dog. The quick brown fox jumps over the lazy dog."> <cfset formatted = "">

<cfoutput>
testString<br>#testString#<br><br>
formatted<br>#formatted#<br><br>
PROCESSING...<br><br>
</cfoutput>
<cfset space = chr(32)>
<cfloop condition="Len(testString) GT 51">
        <cfset Line = Left(testString, 51)>
        <cfset testString = Right(testString, Len(testString)-51)>
        <cfset Break = Find(space, Reverse(Line))>
        <cfif Break GT 1>
                <cfset Rest = Right(Line, Break-1)>
        <cfelse>
                <cfset Rest = "">
        </cfif>
        <cfset Line = Left(Line, 51-Break)>
        <cfset formatted = formatted & Line & "<br>">
        <cfset testString = Rest & testString>
</cfloop>
<cfset formatted = formatted & testString> <cfoutput>

testString<br>#testString#<br><br>
formatted<br>#formatted#<br><br>
COMPLETED<br>
</cfoutput>

I haven't looked at how efficient this is though.

Jo

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve Onnis
Sent: Saturday, 29 January 2005 1:47 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Inserting line breaks after so many charachters

If you do that then your looping into every item. Use the step attribute
then you processing will be a lot quicker aswell

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of grant
Sent: Saturday, January 29, 2005 1:42 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Inserting line breaks after so many charachters

crap i wasn't finished

<cfset insertpoint = 50>
<cfloop on the String>
     <cfset string = insert("<br>", String, insertpoint)>
     <cfset insertpoint = insertpoint + 50> </cfloop>


On Sat, 29 Jan 2005 13:40:45 +1100, grant <[EMAIL PROTECTED]> wrote:
> one could also
> 
> <cfset insertpoint = 50>
> <cfloop on the String>
> 
> </cfloop>
> 
> 
> On Sat, 29 Jan 2005 13:25:18 +1100, Steve Onnis 
> <[EMAIL PROTECTED]>
wrote:
> > Give this ago
> > Just wrote it so haven't tested it, but looks like it would work
> >
> > <!--- The paragraph --->
> > <cfset para = "this is some text that would be your string. the 
> > string
would then have a &lt;br&gt; tag inserted after ever 50th
> > space. this string prolly wont be long enouhg but you try it out.">
> > <!--- split the string into an array using the spaces as the 
> > deilimiter
--->
> > <cfset arr = listToArray(para, " ")>
> > <!--- loop over the array using 50 as the step, that we wont need to
loop over every element --->
> > <cfloop from="1" to="#arrayLen(arr)#" index="i" step="50">
> >        <!--- insert a line break at the end of every 50th array 
> > element
--->
> >        <cfset arr[i] = arr[i] & "<br>"> </cfloop>
> > <!--- convert the array back into a string using the spaces as the
delimiter again --->
> > <cfset str = arrayToList(arr, " ")>
> > <!--- output the string --->
> > <cfoutput>#str#</cfoutput>
> >
> > Steve
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chad
> > Sent: Saturday, January 29, 2005 10:33 AM
> > To: CFAussie Mailing List
> > Subject: [cfaussie] Re: Inserting line breaks after so many 
> > charachters
> >
> > Cool, I'll have a crack.  I know what you mean.  As it is, I barely 
> > had time for Transformers this morning.  ;)
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Phil 
> > Evans
> > Sent: Saturday, 29 January 2005 10:16 AM
> > To: CFAussie Mailing List
> > Subject: [cfaussie] Re: Inserting line breaks after so many 
> > charachters
> >
> > Sorry chad - haven't got time to do the coding for you - if I had 
> > the time I wouldn't be working on a Saturday!
> >
> > Check help for cfloop (Conditional loop), left(), reverse() and
> > replace() functions.
> >
> > HTH
> > Phil.
> >
> > ----- Original Message -----
> > From: "Chad" <[EMAIL PROTECTED]>
> > To: "CFAussie Mailing List" <[email protected]>
> > Sent: Saturday, January 29, 2005 10:11 AM
> > Subject: [cfaussie] Re: Inserting line breaks after so many 
> > charachters
> >
> > > Thanks Phil, my fellow Saturday fellow.  So how would this look in 
> > > code?
> > >
> > >
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > > Phil Evans
> > > Sent: Saturday, 29 January 2005 9:30 AM
> > > To: CFAussie Mailing List
> > > Subject: [cfaussie] Re: Inserting line breaks after so many 
> > > charachters
> > >
> > >
> > > Just a thought -
> > >
> > > Assuming you wanted to have the <br> at 50 characters or before, 
> > > you could break the string up into the chunks of 50, then for each 
> > > chunk, use the reverse function, then replace " " with <br> (by 
> > > default does only the first one), then reverse it again.
> > >
> > > Cheers,
> > > Phil.
> > >
> > > ----- Original Message -----
> > > From: "Chad" <[EMAIL PROTECTED]>
> > > To: "CFAussie Mailing List" <[email protected]>
> > > Sent: Saturday, January 29, 2005 9:23 AM
> > > Subject: [cfaussie] Inserting line breaks after so many 
> > > charachters
> > >
> > >
> > > > Bit of weekend programming here...
> > > >
> > > > How would I go about inserting <br> into a string after so many 
> > > > charactrers without breaking up a word?
> > > >
> > > >
> > > > ---
> > > > You are currently subscribed to cfaussie as: 
> > > > [EMAIL PROTECTED]
> >
> > > > To unsubscribe send a blank email to
> > > [EMAIL PROTECTED]
> > > > Aussie Macromedia Developers: http://lists.daemon.com.au/
> > > >
> > >
> > >
> > > ---
> > > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] 
> > > To unsubscribe send a blank email to 
> > > [EMAIL PROTECTED]
> > > Aussie Macromedia Developers: http://lists.daemon.com.au/
> > >
> > >
> > > ---
> > > You are currently subscribed to cfaussie as: 
> > > [EMAIL PROTECTED] To unsubscribe send a blank email to
> > [EMAIL PROTECTED]
> > > Aussie Macromedia Developers: http://lists.daemon.com.au/
> > >
> >
> > ---
> > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] 
> > To unsubscribe send a blank email to 
> > [EMAIL PROTECTED]
> > Aussie Macromedia Developers: http://lists.daemon.com.au/
> >
> > ---
> > You are currently subscribed to cfaussie as: 
> > [EMAIL PROTECTED] To unsubscribe send a blank email to
[EMAIL PROTECTED]
> > Aussie Macromedia Developers: http://lists.daemon.com.au/
> >
> > ---
> > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To 
> > unsubscribe send a blank email to
[EMAIL PROTECTED]
> > Aussie Macromedia Developers: http://lists.daemon.com.au/
> >
>

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/




---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To
unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/





---
You are currently subscribed to cfaussie as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
Aussie Macromedia Developers: http://lists.daemon.com.au/

Reply via email to