The basic answer to your question is no. You can't 'reach into' a tag
and grab a variable. However, it sounds to me like you are saying that
you need a way for the custom tag to return a dynamic variable name.

A good example of why this is needed: Imagine a custom tag that returns
a variable to caller scope called Result. If you wanted to do this:

<cf_tag x=1>
<cf_tag x=2>

You would 'lose' the Result variable when you called cf_tag the second
time.

There is an easy way around this. Simply tell the tag to return a
dynamic variable name. Add an attribute to your custom tag called r_Var
(or whatever you want). Then, at the end of your tag, do:

<cfset "caller.#attributes.r_Var#" = whatever>

Or

<cfset setVariable("caller.#attributes.r_Var#",whatever)>

Then you can do:

<cf_tag x=1 r_Var="result1">
<cf_tag x=2 r_Var="result2">
<cfoutput>#result1# and #result2#</cfoutput>

If you use cfparam for r_Var, you can even add validation that a valid
variable name was passed - just use type="variableName"

=======================================================================
Raymond Camden, ColdFusion Jedi Master for Macromedia

Email    : [EMAIL PROTECTED]
Yahoo IM : morpheus

"My ally is the Force, and a powerful ally it is." - Yoda 

> -----Original Message-----
> From: Dave Carabetta [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, June 11, 2002 10:38 AM
> To: CF-Talk
> Subject: Call a variable in a Custom Tag?
> 
> 
> I know that, within a custom tag, I can set/update a variables on the 
> calling page using the "caller" scope. However, is there a 
> way to do the 
> opposite? On the calling page, I'd like to "reach in" to the 
> custom tag and 
> pull out a variable that gets set.
> 
> The reason why I'd like to do it this was is that it seems 
> that my custom 
> tag would be a bit more "modular" in that if the tag is 
> called from another 
> application using a different variable name, I'm not dependant on the 
> variable name I've used in the custom tag.
> 
> Thanks,
> Dave.
> 
> 
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.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