Adobe COLDFUSION 9 Manual page 134

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
functions
WriteOutput
• Switch statements
The example uses CFScript without any other ColdFusion tags. It creates a structure of course applicants. This
structure contains two arrays; the first has accepted students, the second has rejected students. The script also creates
a structure with rejection reasons for some (but not all) rejected students. It then displays the accepted applicants
followed by the rejected students and their rejection reasons.
<html>
<head>
<title>CFScript Example</title>
</head>
<body>
<cfscript>
//Set the variables
acceptedApplicants[1] = "Cora Cardozo";
acceptedApplicants[2] = "Betty Bethone";
acceptedApplicants[3] = "Albert Albertson";
rejectedApplicants[1] = "Erma Erp";
rejectedApplicants[2] = "David Dalhousie";
rejectedApplicants[3] = "Franny Farkle";
applicants.accepted=acceptedApplicants;
applicants.rejected=rejectedApplicants;
rejectCode=StructNew();
rejectCode["David Dalhousie"] = "score";
rejectCode["Franny Farkle"] = "too late";
//Sort and display accepted applicants
ArraySort(applicants.accepted,"text","asc");
WriteOutput("The following applicants were accepted:<hr>");
for (j=1;j lte ArrayLen(applicants.accepted);j=j+1) {
WriteOutput(applicants.accepted[j] & "<br>");
}
WriteOutput("<br>");
//sort and display rejected applicants with reasons information
ArraySort(applicants.rejected,"text","asc");
WriteOutput("The following applicants were rejected:<hr>");
for (j=1;j lte ArrayLen(applicants.rejected);j=j+1) {
Last updated 8/5/2010
129

Advertisement

Table of Contents
loading

Table of Contents