Writing formulas can either be done in Crystal or in Basic syntax.
The syntax rules of the basic syntax are very similar to those of Microsoft's Visual Basic and other forms of Basic.
The syntax rules of the crystal syntax are similar to the formula syntax of Crystal Reports.
| Feature | Basic Syntax | Crystal Syntax |
|---|---|---|
| Case-sensitive? | No | No |
| Variable declaration | dim a as number |
numbervar a; |
| Variable assignment | a = 10 |
a := 10; |
| Variable scope | Local: dim aor local aShared: shared aGlobal: global a |
Local: local numbervar a;Shared: shared numbervar a;Global: global numbervar a;or numbervar a;(Default) |
| Comparison operators | 10 < pi()*3 |
10 < pi() * 3; |
| End of statement(s) | Line Break or Colon | Semi-colon |
| Result of formula | Assign return value to variable formula |
Result of last line |
| Comment | ' comment |
// comment |
| If then else statement | global a as number if a = 10 then a = 20 formula = "a was 10" elseif a = 20 then a = 30 formula = "a was 20" else a = 0 formula = "a was not 10 or 20" end if |
numbervar a; if a = 10 then ( a := 20; "a was 10"; ) else if a = 20 then ( a := 30; "a was 20"; ) else ( a := 0; "a was not 10 or 20"; ); |
| "For" loop | formula = "" dim i for i = 1 to 10 step 2 formula = formula + "ab" next i ' Returns: "ababababab" |
stringvar result := ""; numbervar i; for i := 1 to 10 step 2 Do ( result := result + "ab"; ); result; // Returns: "ababababab" |
| "While" loop | formula = "" dim i as number i = 1 do while i <= 10 i = i + 2 formula = formula + "ab" loop |
stringvar result := ""; numbervar i := 0; while i <= 10 Do ( i := i + 2; |
| principles | Basic accepts only statements that "do something". Therefore a single number is not a statement. It may be an expression within an if-condition. But in case you assign that number to a variable it becomes a correct statement because it does an assignment. | In Crystal Syntax everything has a return value - at least "null". As a result everything is a statement and the last evaluated statement delivers the returned value. |
i-net software strives to provide accurate product documentation. Please give us your feedback using the form below.
NOTE: This form is for documentation feedback only. For technical assistance, please send an email to crystalclear@inetsoftware.de.