limit display of text

2004-04-15 Thread Robert Orlini
I have a filed, #report.maint_report_task#, that will be displayed via a cfoutput. How can I display just a portion of what the field contains?

If it contains: blah, blah, blah, blah Because of display constraints, I want it to just display a portion with the three periods after it: blah, blah

Does the trim function factor into this?

Robert O.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: limit display of text

2004-04-15 Thread Douglas.Knudsen
as with most all programming langs, CF has String functions Left(), Right(), and Mid().So for what you want to do, something like this will do
#Left(report.maint_report_task,25)#...

 
see http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/functi17.htm#wp1099887

 
Doug

-Original Message-
From: Robert Orlini [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 11:05 AM
To: CF-Talk
Subject: limit display of text

I have a filed, #report.maint_report_task#, that will be displayed via a cfoutput. How can I display just a portion of what the field contains?

If it contains: blah, blah, blah, blah Because of display constraints, I want it to just display a portion with the three periods after it: blah, blah

Does the trim function factor into this?

Robert O. 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: limit display of text

2004-04-15 Thread Robert Orlini
Thanks much Doug...

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 11:16 AM
To: CF-Talk
Subject: RE: limit display of text

as with most all programming langs, CF has String functions Left(), Right(), and Mid().So for what you want to do, something like this will do
#Left(report.maint_report_task,25)#...

see http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/functi17.htm#wp1099887

Doug

-Original Message-
From: Robert Orlini [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 15, 2004 11:05 AM
To: CF-Talk
Subject: limit display of text

I have a filed, #report.maint_report_task#, that will be displayed via a cfoutput. How can I display just a portion of what the field contains?

If it contains: blah, blah, blah, blah Because of display constraints, I want it to just display a portion with the three periods after it: blah, blah

Does the trim function factor into this?

Robert O. 
_ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: limit display of text

2004-04-15 Thread Bob Haroche
 this will do #Left(report.maint_report_task,25)#...

Out of curiosity, that will trim based on number of characters, yes?
How would one grab the first X number of whole words. IOW trim
characters but stop at a space. Would you need to combine that with
some regex?

-
Regards,
Bob Haroche
O n P o i n tS o l u t i o n s
www.OnPointSolutions.com
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: limit display of text

2004-04-15 Thread Ian Skinner
Something like this I've used before

 
cfset startString = left(aString,REFind([[:space:]],aString,25)

 
This will create a string equal to beginning of aString broke at the first white space character AT or 

--
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA

C code. C code run. Run code run. Please!
- Cynthia Dunning

AFTER character 25.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: limit display of text

2004-04-15 Thread Patric Stumpe
Well you treat the resulting string as a list with space as the
ldelimiter an d delete the last list element. So you get whole only
words with a maximal length as specified in the Left-function.

Anyone else doing it like this?

Patric

 this will do #Left(report.maint_report_task,25)#...

BH Out of curiosity, that will trim based on number of characters, yes?
BH How would one grab the first X number of whole words. IOW trim
BH characters but stop at a space. Would you need to combine that with
BH some regex?

BH -
BH Regards,
BH Bob Haroche
BH O n P o i n tS o l u t i o n s
BH www.OnPointSolutions.com

BH
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: limit display of text

2004-04-15 Thread Larry Lyons
 I have a filed, #report.maint_report_task#, that will be displayed via 
 a cfoutput. How can I display just a portion of what the field 
 contains?
 
 If it contains: blah, blah, blah, blah Because of display 
 constraints, I want it to just display a portion with the three 
 periods after it: blah, blah
 
 Does the trim function factor into this?
 
 Robert O.

You may also want to look at some of the CFlib functions:

For instance, the function MaxLength() does exactly what you want
http://www.cflib.org/udf.cfm?ID=489
Limits the length of string output to a specified length and appends ... to indicate the string has been trimmed. Ideal for limiting a string's length in a table without wrapping.

Another is GetWords()
http://www.cflib.org/udf.cfm?ID=130
Supply a string and number of words to return, this returns that number of words with an ellipsis at the end. If the number of words argument is greater than the actual number of words, the original string will be returned without the ellipsis.

And there's FullLeft()
http://www.cflib.org/udf.cfm?ID=329
An enhanced version of left() that doesn't cut words off in the middle; instead, it searches backward until it finds a full word.

Warnings
Note that FullLeft() acts just like the built-in function Left() in the event only one word is passed to it, or the count parameter is less than the length of the first word in the passed string. 

hth,

larry

--
Larry C. Lyons
Web Analyst
BEI Resources
American Type Culture Collection
email: llyons(at)atcc(dot)org
tel: 703.365.2700.2678
--
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: limit display of text

2004-04-15 Thread Deanna Schneider
Or, you could just use this UDF:

cfscript
/**
 * Displays n number of characters from a string without cutting off in the
middle of a word
 * Code used from FullLeft
 *
 * @param stringString to be modified. (Required)
 * @param numberNumber of characters to include in teaser. (Required)
 * @param urlArgumentURL to use for 'more' link. (Optional)
 * @return Returns a string.
 * @author Bryan LaPlante ([EMAIL PROTECTED])
 * @version 3, July 31, 2003
 */
function FormatTeaser(string,number){
 var urlArgument = ;
 var shortString = ;

 //return quickly if string is short or no spaces at all
 if(len(string) lte number or not refind([[:space:]],string)) return
string;

 if(arrayLen(arguments) gt 2) urlArgument = ... a href=""  arguments[3]
 [more]/a;

 //Full Left code (http://www.cflib.org/udf.cfm?ID=329)
 if(reFind([[:space:]],mid(string,number+1,1))) {
 shortString = left(string,number);
 } else {
if(number-refind([[:space:]], reverse(mid(string,1,number
shortString = Left(string, (number-refind([[:space:]],
reverse(mid(string,1,number);
else shortString = left(str,1);
 }

 return shortString  urlArgument;

}
/cfscript

- Original Message - 
From: Bob Haroche
  this will do #Left(report.maint_report_task,25)#...

 Out of curiosity, that will trim based on number of characters, yes?
 How would one grab the first X number of whole words. IOW trim
 characters but stop at a space. Would you need to combine that with
 some regex?


 -
 Regards,
 Bob Haroche
 O n P o i n tS o l u t i o n s
 www.OnPointSolutions.com


 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]