Chapter 1: ColdFusion Tags
197
CFSET
Use the CFSET tag to define a ColdFusion variable. If the variable already exists, CFSET
resets it to the specified value.
Syntax
<CFSET variable_name=expression>
Arrays
The following example assigns a new array to the variable "months".
<CFSET months=ArrayNew(1)>
This example creates a variable "Array_Length" that resolves to the length of the array
"Scores".
<CFSET Array_Length=ArrayLen(Scores)>
This example assigns to index position two in the array "months" the value "February".
<CFSET months[2]="February">
Dynamic variable names
In this example, the variable name is itself a variable.
<CFSET myvariable="current_value">
<CFSET "#myvariable#"=5>
COM objects
In this example, a COM object is created. A CFSET defines a value for each method or
property in the COM object interface. The last CFSET creates a variable to store the
return value from the COM object’s "SendMail" method.
<CFOBJECT ACTION="Create"
NAME="Mailer"
CLASS="SMTPsvg.Mailer">
<CFSET MAILER.FromName=form.fromname>
<CFSET MAILER.RemoteHost=RemoteHost>
<CFSET MAILER.FromAddress=form.fromemail>
<CFSET MAILER.AddRecipient("form.fromname", "form.fromemail")>
<CFSET MAILER.Subject="Testing CFOBJECT">
<CFSET MAILER.BodyText="form.msgbody">
<CFSET Mailer.SMTPLog="logfile">
<CFSET success=MAILER.SendMail()>
<CFOUTPUT> #success# </CFOUTPUT>
Содержание COLDFUSION 4.5-CFML LANGUAGE
Страница 1: ...Allaire Corporation CFML Language Reference ColdFusion 4 5...
Страница 207: ...Chapter 1 ColdFusion Tags 183 CFCATCH CFTRY BODY HTML...
Страница 224: ...200 CFMLLanguageReference CFOUTPUT P Text within CFOUTPUT is always shown CFOUTPUT BODY HTML...
Страница 296: ...272 CFMLLanguageReference INPUT TYPE text NAME number2 BR INPUT TYPE submit NAME submit VALUE Add FORM BODY HTML...
Страница 336: ...312 CFMLLanguageReference CFIF BODY HTML...
Страница 404: ...380 CFMLLanguageReference DE It is morning CFOUTPUT P BODY HTML...
Страница 413: ...Chapter 2 ColdFusion Functions 389 Customer BalanceDue BR CFOUTPUT CFIF BODY HTML...
Страница 483: ...Chapter 2 ColdFusion Functions 459 CFOUTPUT CFLOOP BODY HTML...
Страница 557: ...Chapter 2 ColdFusion Functions 533 P CFOUTPUT Value i is employee keysToStruct i CFOUTPUT P CFLOOP CFIF BODY HTML...
Страница 584: ...560 CFMLLanguageReference...
Страница 594: ...570 CFMLLanguageReference...