Very nice.

Here's another one at CFLib.

http://www.cflib.org/udf.cfm?ID=249


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 2:20 PM
To: CF-Talk
Subject: RE: Wrapping Text


Function to wrap a string before a specific number of characters.


<cfscript>
        function WrapText(string, count){
                var start = 1;
                var stringlen = len(string);
                while(start LTE stringlen){
                        newstring = reverse(trim(mid(string, start,
count)));
                        spaceat = refind("[[:space:]]", newstring, start);
                        where = start + (count - spaceat);
                        if(where LTE stringlen){string = insert("<br>",
string, where);}
                        amount = count - spaceat;
                        if(amount EQ 0){amount = count;}
                        start = start + amount;
                }
                return string;
        }
</cfscript>

<cfset string = "dskljds skjdsl kjdf sdk fdslk dslkjdsljksdlk d jkljd
sakladk dfkjf lk ;sdfj klsdkl jflksdf sdfkj dsklf lkjfdsk jdfk
jfkljdkjflkalkf lkj dslkj fkl fa jlkafkj dafljka kl af lkfa lkasdj dfj sdfj
f ldsf kjdslk dfkljdfl sdfkjds lfdskldslj sfdlkjlkdflkjsd fdslk jkjl fslkj
kj lfdslfkflkj fkljk fdskjlsksdljk kljkldsjdslkdsf fsdklfjlk  f sdljkdsklf
lkdsfjlkj fkjf kljf sljkf flkjf jfsdjkfwfeoiejfijdmmmc oimc i ocpj pjic
ijoiji o">

<cfoutput><p>#WrapText(string, 90)#</p></cfoutput>

Anthony Petruzzi
Webmaster
954-321-4703
[EMAIL PROTECTED]
http://www.sheriff.org


-----Original Message-----
From: Greg [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 2:05 PM
To: CF-Talk
Subject: Wrapping Text


I'm trying to get a long text string to wrap properly in a printable
report. Anyone have a graceful way of finding the last space before a
certain character, say 90? Also, I could use fixedsys font to be sure
that 90 is always a good wrapping point. Is that the best option?



______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to