RE: limiting output of text

2006-10-09 Thread Andy Matthews
It would be more efficient to only return what you need from the database.
Assuming you're using MySQL, the query would look like this:

SELECT LEFT(myColumn,100)
FROM tablename

That way you only get what you plan on using.

!//--
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
[EMAIL PROTECTED]
615.370.1530 x737
--//-

-Original Message-
From: terry yee [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 08, 2006 4:36 PM
To: CF-Talk
Subject: limiting output of text


Hi,

Am calling text from datasource and need to display only a small portion of
it. ie. first 100 characters etc..
 my code:

cfif len(getRewards.reward_description)
#Replace(Trim(getRewards.reward_description), Chr(10), br  ,
ALL)# /cfif

cheers
terry



~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255956
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4


Re: limiting output of text

2006-10-09 Thread Larry Lyons
What about
cfoutput#Left(getRewards.reward_description, 100)#/cfoutput

On 10/8/06, terry yee [EMAIL PROTECTED] wrote:


The problem with this solution is that it may cut off words in the middle once 
you've hit the 100 count. A better solution is to stop at the nearest word. 
There's UDF in cflib.org that does just that: 

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

From the site:
 Description
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 C. Lyons
Web Analyst
BEI Resources
American Type Culture Collection
http://www.beiresources.org
email: llyons(at)atcc(dot)org
tel: 703.365.2700.2678
--

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255957
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: limiting output of text

2006-10-09 Thread Denny Valliant
On 10/8/06, Richard Dillman [EMAIL PROTECTED] wrote:

 www.cflib.org has a UDF called
 *FullLeft(str, count)  *
 allows you to do a left on a string and only trim at the end of whole
 words.

 Some how i see triming at the last word being the next question :-)


LOL!


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:256068
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: limiting output of text

2006-10-08 Thread Jason Radosevich
What about
cfoutput#Left(getRewards.reward_description, 100)#/cfoutput

On 10/8/06, terry yee [EMAIL PROTECTED] wrote:
 Hi,

 Am calling text from datasource and need to display only a small portion of 
 it. ie. first 100 characters etc..
  my code:

 cfif len(getRewards.reward_description)
#Replace(Trim(getRewards.reward_description), Chr(10), br  , 
 ALL)# /cfif

 cheers
 terry

 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255933
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: limiting output of text

2006-10-08 Thread terry yee
Cheers,

Just what i needed

What about
cfoutput#Left(getRewards.reward_description, 100)#/cfoutput

On 10/8/06, terry yee [EMAIL PROTECTED] wrote:


~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255934
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: limiting output of text

2006-10-08 Thread Denny Valliant
Heh. I don't know why I don't like cfif len(something) in the same manner
I don't like cfif recordcount, but anywayze... ;-]

cfset dis_reward_description = Replace(Trim(reward_description),
Chr(10),br / ,ALL)
cfif len(dis_reward_description) gt 97
  #left(dis_reward_description,97)#...
cfelseif len(dis_reward_description) gt 0
  #dis_reward_description#
/cfif

And you may consider a fixed-width font so the kerning(sp?) doesn't
defeat this attempt at making things even.

I left the query name off, as it maybe should be, so long as it's in
the main query loop.
Otherwise, you'd want someQ.someField[someQ.currentrow], I
think.  I don't know.  I'm not the best practicer of scoping by a long
shot.

Hehehe,
-Denny

On 10/8/06, terry yee [EMAIL PROTECTED] wrote:
 Hi,

 Am calling text from datasource and need to display only a small portion of 
 it. ie. first 100 characters etc..
  my code:

 cfif len(getRewards.reward_description)
 #Replace(Trim(getRewards.reward_description), Chr(10), br  , 
 ALL)# /cfif

 cheers
 terry

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255937
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: limiting output of text

2006-10-08 Thread Richard Dillman
www.cflib.org has a UDF called
*FullLeft(str, count)  *
allows you to do a left on a string and only trim at the end of whole words.

Some how i see triming at the last word being the next question :-)


On 10/8/06, Denny Valliant [EMAIL PROTECTED] wrote:

 Heh. I don't know why I don't like cfif len(something) in the same
 manner
 I don't like cfif recordcount, but anywayze... ;-]

 cfset dis_reward_description = Replace(Trim(reward_description),
 Chr(10),br / ,ALL)
 cfif len(dis_reward_description) gt 97
 #left(dis_reward_description,97)#...
 cfelseif len(dis_reward_description) gt 0
 #dis_reward_description#
 /cfif

 And you may consider a fixed-width font so the kerning(sp?) doesn't
 defeat this attempt at making things even.

 I left the query name off, as it maybe should be, so long as it's in
 the main query loop.
Otherwise, you'd want someQ.someField[someQ.currentrow], I
 think.  I don't know.  I'm not the best practicer of scoping by a long
 shot.

 Hehehe,
 -Denny

 On 10/8/06, terry yee [EMAIL PROTECTED] wrote:
  Hi,
 
  Am calling text from datasource and need to display only a small portion
 of it. ie. first 100 characters etc..
   my code:
 
  cfif len(getRewards.reward_description)
  #Replace(Trim(getRewards.reward_description), Chr(10), br
  , ALL)# /cfif
 
  cheers
  terry

 

~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255938
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


RE: limiting output of text

2006-10-08 Thread Bobby Hartsfield
This will trim the text (str) at the specified length (trimat) and then
delete everything AFTER the last space it finds. This way no words get cut
in half. This is a much scaled down version of what I use for 'teasers' to
articles. This method simply removes html rather than take them in to
account when trimming the length.

cfscript
function teaserText(str,trimat)
{
if(len(str) gt trimat)
{
// Remove any html tags so they aren’t counted in the length
str = rereplace(str, .*?, , all);

//Cut the text at the desired length
str = left(str, trimat);

//Delete everything after the last space character
str = listdeleteat(str, listlen(str,  ),  );

//Add '...' to the end to indicate that there is more to 
//read than what you see here
str = str  ...;
}

return str;
}
/cfscript

cfoutput#teasertext(thetext, 150)#/cfoutput



-Original Message-
From: terry yee [mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 08, 2006 5:36 PM
To: CF-Talk
Subject: limiting output of text

Hi,

Am calling text from datasource and need to display only a small portion of
it. ie. first 100 characters etc..
 my code:

cfif len(getRewards.reward_description)
#Replace(Trim(getRewards.reward_description), Chr(10), br  ,
ALL)# /cfif

cheers
terry



~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four 
times a year.
http://www.fusionauthority.com/quarterly

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:255943
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4