###

### Defining a Rule in the Rule Tree Editor

To define a rule using the Rule Tree Editor dialog box, follow this procedure:

1. Select File | Reporting | New | Report Template to access the Report Template Editor.

2. Add a TextReportObject, CadReportObject, or a Label object onto the template.

3. Right-click on the object. A Properties dialog box appears.

4. Select the Rules Tree property from the Properties dialog box. The Rule Tree Editor dialog box appears. You will see a list of various items making up a part program. Many of these items you can expand by clicking on a plus symbol (+) to view more specific items or commands. Some items exists on their own and aren't inside of any expanding lists, these items include:

   Rule Tree Editor dialog box

   - Top of First Page in Section - If you select this item, you can select a label or text expression to display at the top of the first page in the current section of your Report window.

   - Bottom of Last Page in Section - If you select this item, you can select a label or text expression to display at the bottom of the last page of the current section.

   - File Header - If you select this item, you can select a label or text expression to display in the place of the usual report's file header of PART NAME, REV NUMBER, SER NUMBER, and STATS COUNT. The File Header label or text will appear on the first page in the current section of your report.

5. Define conditions to be met.

   - From the list of items, find an item that you want to define as a condition.

   - Select the item and click Add. The Edit Rule dialog box appears.

     Edit Rule dialog box

   - If you want to define another condition, you can choose either a reporting language expression or a BASIC script as your condition. To do this, select the Use Additional Expression or Script check box, and then in the Conditional area, select either the Expression or Script option.

   - - If you selected Expression, type the expression for your condition into the Conditional Expression box. For example, if you are creating a rule for a measured circle, you can test any of the circles data type field values to control whether or not to display a label. Suppose you only want to display a label if the measured circle has less than four hits. In the Conditional Expression box, you would type:
       N_HITS < 4
       Then if this condition evaluated to TRUE, PC-DMIS would use the associated label. Note that you don't need to include the entire IF expression statement. The IF statement is already understood and evaluated in this box.

     - If you selected Script, click the Edit button to create your BASIC script. A VBS Mini-editor appears where you can type your code. Create your script inside this code editor. The script must return TRUE for the condition to be met. When finished, right-click and select Check Syntax. Click OK when finished. PC-DMIS automatically stores the script with the defined rule.

Note: If the rule ever gets deleted, you will lose your script. You should store your script in a separate text file if you are concerned about it getting deleted.

6. Define a label or expression to display if the condition or conditions defined are met.

   - With the Edit Rule dialog box open, choose either Use Text Expression for Report or Use Label Template for Report.

   1. - If you chose to use a text expression, type a simple text message or define an expression in the Text Expression box. For example, whenever PC-DMIS measured a circle, you can type static text such as:
        "We just measured a circle!"
        Or, you could use expressions to include information about the circle, such as:
        "We just measured a circle! It had " + N_HITS + " hits!"

      - If you chose to use a label template, select a label template. Note that this field also accepts expressions as long as the expression evaluates to a label template name. Remember, if you use an expression in this field, be sure to precede it with the "=" symbol. If desired, click the Grid Format button to access the Table Format Properties dialog box. Using this dialog box, you can define a grid format for your report. A grid format lets you reorder or hide your columns and rows without creating a brand new label template. Additionally, defining a grid format also lets you use the TABLE/FORMAT Edit window command to control row and column ordering from within the part program. See "Using the Table Format Properties dialog box".

   - When you have filled out the Edit Rule dialog box, click OK. PC-DMIS places the item from the list in a boldface font and inserts the rule for that item at the bottom of the Rule Tree Editor dialog box.

7. Organize your rules. You can have as many rules as you want for a given command type. If you have more than one rule, PC-DMIS will evaluate the rules in the order that they appear. You can change the evaluation order by selecting a rule and clicking Move Up or Move Down in the Rule Tree Editor dialog box.

- - You can copy and paste rules from one item to another item or to multiple items, or to an entirely different tree by using the Copy and Paste buttons. See "Copying and Pasting Rules".

  - You can remove rules from an individual item by clicking Delete or Clear. If you want to remove the rules for multiple items, you can select them and click Clear. See "Clearing Rules"

6. Click OK to save changes made to the Rule Tree Editor.

7. Test the rule.

6. - Save the report template.

   - Apply the report template to the report data by using the Reporting toolbar on the Report window.

   - Execute the part program.

Important: Be aware that a rule assigned to a child element always overrules a rule assigned to a parent element. Also, a rule assigned to a parent node applies to each child element of that node that does not contain its own rule.

A toolbar at the bottom of this window lets you control the demo. When you finish viewing this demo, click the blue icon again to close this expanded window.