Name
SetVariable
Synopsis
SetVariable(variablename, value
)
Assigns value
to
variablename
where
value
is any passed value.
SetVariable( )
is useful when you want to create
dynamically named variables. The following example uses
SetVariable( )
to assign values to several
dynamically created variables:
<CFLOOP INDEX="index" FROM="1" TO="10"> <CFSET ValueOfVariable = SetVariable("MyVar#index#", #Index#)> </CFLOOP> <CFLOOP INDEX="pos" FROM="1" TO="10"> <CFOUTPUT>MyVar#pos# = #Evaluate("MyVar"&"#pos#")#<BR></CFOUTPUT> </CFLOOP>
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.