Hhm, so its not a stupid idea thus far... Well lets continue with the idea then..
Made the changes you suggested, although not 100% sure why..
One problem I am still getting is too much white space ;-))
Seriously, it is putting a tab in or something somewhere, I tried cfsilent in the
component itself but nothing, have a look.
** in the meantime I changed output="true" to output="false" and the space is gone,
funny though how cfsilent did not do anything.
<cfscript>
obj = createObject("component", "intranet.development.component.output");
</cfscript>
<cfset firstName = "Taco Fleur.">
#obj.fnOutput( variables, 'firstName', 'fail' )##obj.fnOutput( variables, 'firstName',
'fail' )#
Returns Taco Fleur. Taco Fleur. **notice the white space between the two strings..
<cfcomponent displayname="Output"
hint="">
<!--- ***************** Function ***************** --->
<cffunction access="public"
name="fnOutput"
output="false"
returntype="string"
displayname=""
hint="">
<cfargument name="scope"
type="struct"
required="true"
displayname="Scope">
<cfargument name="identifier"
type="string"
required="true"
default="variables"
displayname="Scope">
<cfargument name="onError"
type="string"
required="true"
default="display"
displayname="On Error">
<cfset var result = "">
<cftry>
<cfset result = arguments.scope[ arguments.identifier ]>
<cfcatch type="any">
<cfswitch expression="#arguments.onError#">
<cfcase value="display">
<cfset result = "[Error]">
</cfcase>
<cfcase value="nothing"></cfcase>
<cfcase value="fail">
<cfthrow message="#cfcatch.message#"
type="Custom"
detail="#cfcatch.detail#">
</cfcase>
<cfdefaultcase><!--- This should never happen
---></cfdefaultcase>
</cfswitch>
</cfcatch>
</cftry>
<cfreturn result>
</cffunction>
</cfcomponent>
-----Original Message-----
From: Sean Corfield [mailto:[EMAIL PROTECTED]
Sent: Thursday, 1 July 2004 2:40 PM
To: CFAussie Mailing List
Subject: [cfaussie] Re: Stupid idea?
> I want more control on what happens when there is an error, for
> example I want to have a choice when I output something like
> #insignicantVariable# to display
>
> [Error] to the user, nothing or fail.
>
> #obj.fnOutput( variables, 'firstName', 'fail' )#
>
> Now tell me, how stupid is this and why?
I don't think it's stupid. I can see it being pretty useful actually.
The only issue is you're trying to output the result of the function
call but you declared it to return void - I think you need to have
returntype="string" and <cfreturn "[Error]" /> / <cfreturn "" /> as
appropriate.
---
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/
Register now for the 3rd National Conference on Tourism Futures, being held in
Townsville, North Queensland 4-7 August - www.tq.com.au/tfconf
---
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/