#Decision Making Structures
- Operators
CFML and CFScirpt | CF8+ CFScript Only --- | --- | --- IS, EQUAL, EQ | == IS NOT, NOT EQUAL, NEQ | != GT, GREATER THAN, LT, LESS THAN, GTE, LTE | >, <, >=, <= CONTAINS | N/A DOES NOT CONTAIN | N/A
- Join conditions
CFML and CFScript | CF8+ CFScript Only |
---|---|
AND | && |
OR | // (two vertical bars) |
NOT | ! |
XOR | N/A |
EQV | N/A |
IMP | N/A |
- CFML
<cfif n1 GTE n2>
<h1>N1 is greater or equal than N2</h1>
<cfelse>
<h1>N1 is less or equal than N2</h1>
</cfif>
- CFScript
<cfscript>
if (N1 >= N2) {
...some code...;
} else {
...some other code...;
}
</cfscript>
- CFML
<cfif n1 GT n2>
<h1>N1 is greater than N2</h1>
<cfelseif n1 EQ n2>
<h1>N1 is equal to N2</h1>
<cfelse>
<h1>N1 is less than N2</h1>
</cfif>
- CFScript
<cfscript>
if (N1 > N2) {
...greater than code...;
} else if (N1 == N2) {
...code for equality...;
} else {
...less than code...;
}
</cfscript>
- CFML
<cfswitch expression="#myVar#">
<cfcase value="1">
...code...
</cfcase>
<cfcase value="9,10"> <!---9 or 10--->
...code...
</cfcase>
<cfdefaultcase>
...finally...
</cfdefaultcase>
</cfswitch>
- CFScript
<cfscript>
switch (myVar) {
case 1:
...some code...;
break;
case 9:
...some code...;
break;
default:
...default code...;
break;
}
</cfscript>
<cfscript>
x = (myVar == 1) ? 1 : 277;
</cfscript>
Prefix | Scope | What is for? | Required? |
---|---|---|---|
var | current page | default | NO |
URL | current page | values pased on the query string | NO |
CGI | any page | server environment variables | NO |
FORM | current page | values pased through a form | NO |
COOKIE | any page | values to keep in the client machine | NO |
CLIENT | any page | varaibles created using the client prefix | NO |
ARGUMENTS | local to the function or component method | values required by the function or method | NO |
SESSION | any page for the duration of a client session | client info | YES |
APPLICATION | any page to all users until application restarted | info global to the application | YES |
SERVER | any page that is delivered from specific server | server information | YES |