背景
- 我正在尝试对报告的详细信息行进行一些美观的验证。
- 我有几个名为 Assert 语句的公式,如果测试失败则返回 false,如果通过则返回 true。
Goal
- 我想创建一个存储“违反规则”的数组,然后将它们显示在行末尾的字段中,标题为“违反规则”
到目前为止我做了什么
- 创建一个数组并将其初始化为报告标题中的空字符串数组
- 创建一个公式来评估每个规则,增加数组,并添加损坏的规则编号(这是每个规则的重复代码,没什么花哨的)。这被添加到我的详细信息显示上方的隐藏详细信息部分中。
- 创建了一个公式,该公式是规则破坏数组中元素的联接。这是与我的详细信息字段一起显示的公式。
- 创建了一个公式将规则损坏数组设置为空。在我的详细信息显示后,这会出现在隐藏的详细信息部分中。
Problem
- Crystal 似乎不允许我找到“end if”语句。
- 因此,看来我只能计算一个 If 语句,而不能计算单个公式中的多个语句。
- 这意味着我不能执行多个 if,每个规则一个。
示例代码
创建数组(名为 Init_StringVar_Array_RulesBroken 的公式):
//@Init
//This goes into the report header
WhilePrintingRecords;
//initializes the array of broken rules which we'll add to during details
StringVar Array RulesBroken;
"";
递增数组并添加值的前三个规则评估的示例(位于名为 Increment_StringVar_Array_RulesBroken 的公式中):
//@Increment
//Goes before the details section is displayed
//accesses the shared variable
WhilePrintingRecords;
StringVar Array RulesBroken;
//separate if statement for each assert statement
//01
if not {@Assert_01_IfCrewIsConstructionCrew_CBFlagShouldBeYesOrDirect} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "01"; //adds the new string into the array
//02
if not {@Assert_02_IfCrewIsConstructionCrew_AndCBFlagIsDirect_WONumberShouldStartWithC} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "02"; //adds the new string into the array
//03
if not {@Assert_03_IfCrewIsDesign_AndCBFlagIsDirect_WONumberShouldStartWithD} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1]; //extends the array to be able to hold one more item than it does currently
RulesBroken[UBound(RulesBroken)] := "03"; //adds the new string into the array
有任何想法吗?
- Crystal Reports 中是否有 If / then / end if 功能?
- 如果没有,水晶报表中是否有解决此类问题的方法?我是否需要为每个公式创建多个公式并确保将它们放在另一个公式之后或类似的东西?
预先感谢您的任何帮助!
使用您拥有的代码执行此操作的最简单方法是将 if 块括在括号中并用分号分隔它们:
//01
(
if not {@Assert_01_IfCrewIsConstructionCrew_CBFlagShouldBeYesOrDirect} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
RulesBroken[UBound(RulesBroken)] := "01"
else ""
);
//02
(
if not {@Assert_02_IfCrewIsConstructionCrew_AndCBFlagIsDirect_WONumberShouldStartWithC} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
RulesBroken[UBound(RulesBroken)] := "02"
else ""
);
//03
(
if not {@Assert_03_IfCrewIsDesign_AndCBFlagIsDirect_WONumberShouldStartWithD} then
Redim Preserve RulesBroken[UBound(RulesBroken) + 1];
RulesBroken[UBound(RulesBroken)] := "03"
else ""
);
我添加了缩进,指示 Crystal 如何解释这些块。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)