Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
cfl_ch_2-the_cfl_language [2019/02/20 10:41]
kcifreo
cfl_ch_2-the_cfl_language [2019/02/20 10:51] (current)
kcifreo
Line 21: Line 21:
 //''​ Declare x : 3*4 ; '' ​ //''​ Explain what x is used for here ''​ //''​ Declare x : 3*4 ; '' ​ //''​ Explain what x is used for here ''​
 </​code>​ </​code>​
 +
 A **multi-line comment** begins with an open curly bracket ({) and ends with a closed curly bracket (}). A **multi-line comment** begins with an open curly bracket ({) and ends with a closed curly bracket (}).
 <​code>​ <​code>​
Line 126: Line 127:
 </​code>​ </​code>​
  
-CFL treats Booleans as a special case of the number type mentioned already. Zero (0) is considered NO or FALSE, whereas one ((3 4AND (1 1))  is considered to be YES or TRUE.+CFL treats Booleans as a special case of the number type mentioned already. Zero (0) is considered NO or FALSE, whereas one <sup>((1)))</​sup> ​ is considered to be YES or TRUE.
  
 **DateTime Types** **DateTime Types**
Line 194: Line 195:
 |AND||Logical AND||  False|| |AND||Logical AND||  False||
 |NOT||Negation||( Not (3 4) ) True|| |NOT||Negation||( Not (3 4) ) True||
-|OR||Logical OR||((3 4OR (1 1))  True|| +|OR||Logical OR||<sup>((2)))</​sup> ​ ​True|| 
-|XOR||Logical XOR||((3 ​4XOR (1 1))  True||+|XOR||Logical XOR||<sup>((3)))</​sup> ​ ​True||
  
 **DateTime Operators** **DateTime Operators**
Line 251: Line 252:
 will not give an error. will not give an error.
  
-**Temporary Variables** Complex formulas are easier (and usually faster) if they are broken down into steps. Temporary variables are ideal for such occasions. Temporary variables are created within the CFL block and do not retain their values after the evaluation of the block is complete. (This is in contrast to Global Variables, which is discussed later.) +**Temporary Variables** Complex formulas are easier (and usually faster) if they are broken down into steps. Temporary variables are ideal for such occasions. Temporary variables are created within the CFL block and do not retain their values after the evaluation of the block is complete. (This is in contrast to Global Variables, which is discussed later.) Temporary variables use the "​DECLARE"​ keyword and can be assigned a value immediately or upon later use, as in this example:
-Temporary variables use the "​DECLARE"​ keyword and can be assigned a value immediately or upon later use, as in this example: +
 <​code>​ <​code>​
 // First, convert the temperature Global Variable to Centigrade // First, convert the temperature Global Variable to Centigrade
Line 265: Line 264:
 </​code>​ </​code>​
  
-Note that the assignment operator is the colon-equals,​ and not just the equal sign as in some programming languages. This is to prevent confusion with the comparison operator. In this example, the temporary variable "​Centigrade"​ converted the global variable "​Temperature"​ to degrees C. From this, CFL calculated the expansion coefficient. This entire calculation could not be done in one step, and the multiple-step approach makes the logic easier to follow. +Note that the assignment operator is the colon-equals,​ and not just the equal sign as in some programming languages. This is to prevent confusion with the comparison operator. In this example, the temporary variable "​Centigrade"​ converted the global variable "​Temperature"​ to degrees C. From this, CFL calculated the expansion coefficient. This entire calculation could not be done in one step, and the multiple-step approach makes the logic easier to follow. As in the example above, temporary variables are not limited to numbers. They can be any of the CFL data types, including Objects!
-As in the example above, temporary variables are not limited to numbers. They can be any of the CFL data types, including Objects!+
  
 <​code>​ <​code>​
Line 285: Line 283:
 Referral + "​referred by " + Salesperson Referral + "​referred by " + Salesperson
 </​code>​ </​code>​
- 
- 
  
 **Units** One of the most powerful features of CFL is the built-in support for units. Units are written in CFL just as in high-school science: after the number or variable they modify. **Units** One of the most powerful features of CFL is the built-in support for units. Units are written in CFL just as in high-school science: after the number or variable they modify.
Line 299: Line 295:
 ELSE "​Error"​ ENDIF ELSE "​Error"​ ENDIF
 </​code>​ </​code>​
- 
  
 Here are some simple rules to remember about using units: Here are some simple rules to remember about using units:
Line 572: Line 567:
   * **condition**.   * **condition**.
   * **maxloops**. This optional identifier sets a maximum number of loops that the loop will perform. If this limit is reached, execution automatically moved to the line of CFL following the loop.   * **maxloops**. This optional identifier sets a maximum number of loops that the loop will perform. If this limit is reached, execution automatically moved to the line of CFL following the loop.
- \\ An example of the WHILE statement follows: ​''​ WHILE (condition) [MAXCOUNT = maxloops] DO ExpressionBlock ; ENDWHILE; ''​ ''''​+ \\ An example of the WHILE statement follows:
  
-''''''''​+<​code>​ 
 +[[code|]]
  
-----+===WHILE===
  
-''''''''​+Use **WHILE** statements to create loops that execute if and while something is true. 
 +The syntax for the WHILE statement is as follows. Since white space does not matter, a different style can be used. 
 +</​code>​
  
-''''​+WHILE (condition) [MAXCOUNT = maxloops] DO
  
-''''​+ExpressionBlock;​
  
-''''​+ENDWHILE;
  
-''''​ +<​code>​ 
- +The pieces of the WHILE statement are: 
-''''​+* **condition**. 
 +* **maxloops**. This optional identifier sets a maximum number of loops that the loop will perform. If this limit is reached, execution automatically moved to the line of CFL following the loop. 
 +</​code>​
  
 \\ \\