Crystal Reports for Rational Application Developer 设计员指南

多个表达式(Crystal 语法)

一般情况下,每个表达式占一行,但如果表达式需要更多的空间,可以在下一行续写该表达式。
下面的公式由五个表达式组成。由于公式中最后一个表达式返回公式的值,因此该公式返回的值为“数字”值 25。
示例
//Expressions example
//The first expression. Its value is the Number
//value 30
10 + 20;
//The second expression. Its value is the String
//"Hello World". It takes up two lines.
"Hello " +
"World";
//The third expression. Its value is of Number type
{Orders Detail.Quantity} * 2 - 5;
//The fourth expression. Its value is of String type
If {Orders Detail.Quantity} > 1 Then
"multiple units"
Else
"one unit";
//The fifth and final expression. Its value is the
//Number value 25
20 + 5
也允许在公式中最后一个表达式的后面加上分号,但这是可选的。例如,上述公式的末尾可以是:
20 + 5;
“表达式(Crystal 语法)”一节中,某些示例公式没有分号。这是因为这些示例由单个表达式组成,并且最后一个表达式后面的分号是可选的。使用 Crystal 语法的许多表达式可以作为单个表达式编写。
注意:在“multiple units”字符串后没有分号。事实上,如果在这里加上分号,程序将报告错误。这是因为分号分隔表达式,而
Else
"one unit";
不是单独的表达式。它不能与 If 分开而独立存在。事实上,由于在某些情况下,该字符串描述 If 表达式将返回的值,所以它是 If 表达式的完整部分。

注意: 该示例并不符合实际情况,因为公式中的前四个表达式对最后一个表达式没有任何影响。



Business Objects,SAP 子公司
http://www.china.businessobjects.com/
支持服务
http://www.china.businessobjects.com/support/
Web 上的产品文档
http://support.businessobjects.com/documentation/