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 MX, 2nd Edition 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.