I already know the answer to this, but I thought I would see what it might
inspire....

Is it possible to write a custom function? Here is an example of what I
would like to be able to do. The following code limits the display of lname
to 8 characters....

<cfif len(lname) GT 8>#Left(lname, 8)#...<cfelse>#lname#</cfif>

What I was wondering is if I could somehow create a function, and then call
it like so (this is what I really want to know)...

#StringLimit(lname, 8)#

Maybe I've been playing around too much with Javascript, but this seems
logical. I know I can write a custom tag...

<!----StringLimit.cfm---->
<cfparam name="attributes.value" default="">
<cfparam name="attributes.limit" default="0">
<cfparam name="attributes.tail" default="...">
<cfif len(attributes.value) GT attributes.limit>#Left(attributes.value,
attributes.limit)##attributes.tail#<cfelse>#attributes.value#</cfif>

<!---- Call it as a tag ---->
<cf_StringLimit
    value="#lname#"
    limit="8"
    tail="..."
>

Are there other guru secrets anyone wants to share on this topic?

Thanks,
Steve



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to