Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 15 Editing Rules : Using Available Primary Commands

Using Available Primary Commands
APPEND Command
The primary command APPEND appends a rule onto the rule currently being edited. The APPEND command appends the actions at the end of the action part and the exception handlers at the end of the exception handler part of the rule being edited. The rule is checked for syntax before it can be saved.
APPEND does not append local variables and conditions, and it does not add action sequence numbers for the appended action part. You must supply these as required.
Issue the APPEND command as shown:
RULE EDITOR ===> APPEND DEPARTMENTS<Enter>
The following screen shows the DEPARTMENTS rule appended to the ­EMPLOYEES_RAISE rule, after the line END;.

 
RULE EDITOR ===> SCROLL: P
EMPLOYEES_RAISE(JOBTITTLE, REGION);
_ LOCAL RAISE, RATE;
_ ---------------------------------------------------------------------------
_ JOBTITLE = 'SENIOR ANALYST'; | Y N N
_ JOBTITLE = 'ANALYST'; | Y N
_ ------------------------------------------------------------+---------------
_ RATE = 0.1; | 1
_ RATE = 0.05; | 1
_ RATE = 0.02; | 1
_ GET EMPLOYEES(REGION) WHERE POSITION = JOBTITLE; | 2
_ FORALL EMPLOYEES(REGION) WHERE POSITION = JOBTITLE: | 2 2 3
_ RAISE = EMPLOYEES.SALARY * RATE; |
_ EMPLOYEES.SALARY = EMPLOYEES.SALARY + RAISE; |
_ CALL REPLACE_SALARY(REGION); |
_ CALL MSGLOG(EMPLOYEES.LNAME || ' NOW EARNS ' || |
_ EMPLOYEES.SALARY); |
_ END; |
_ FORALL DEPARTMENTS: |
_ FORALL EMPLOYEES('EDUC') WHERE DEPTNO = |
_ DEPARTMENTS.DEPTNO: |
_ CALL MSGLOG(' LAST NAME = '|| EMPLOYEE.LNAME || |
PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
CANCEL Command (PF12)
If you decide not to save changes to a rule, you can cancel the changes by typing the primary command CANCEL in the primary command field and pressing Enter, or by pressing PF12. When you issue the command, the Rule Editor cancels editing changes and returns you to your previous screen.
CHANGE Command
To change an instance of a particular token use the primary command CHANGE. Type in the CHANGE command as follows:
RULE EDITOR ===> CHANGE search_token replacement_token<Enter>
To change the first instance of the token REGION to the token LOCATION in the EMPLOYEES_RAISE rule, issue the CHANGE command as shown:
RULE EDITOR ===> CHANGE REGION LOCATION<Enter>
Usage Notes
The search for the token begins immediately to the right of the cursor position (not at the beginning of the rule) and, if successful, replaces the first instance of the token and positions the cursor at the start of the replaced token. Use PF6 to find the next instance of the token and replace it.
If you are unsure whether you want to change the next instance, you can first find the instance by pressing PF5. To replace it press PF6. To skip it and search for the next instance press PF5.
If the search for the token is unsuccessful, a message appears on the message line informing you that the token is not found. The message means that the search failed to find an instance of the token between the current cursor position and the end of the rule. Pressing PF5 or PF6 resumes the search from the beginning of the rule.
CHANGE … ALL Command
The CHANGE command has an optional argument, ALL. This argument changes the scope of the CHANGE command from the next occurrence of the search token to all the occurrences of the search token in the rule. Specify the ALL argument as follows:
RULE EDITOR ===> CHANGE search_token replacement_token ALL<Enter>
If a CHANGE … ALL command makes changes, the message line tells how many occurrences of the search token are replaced. If the search token does not occur in the rule, the message line informs you of this.
COPY Command
The COPY primary command causes the current rule to be replaced, except its name, with a copy of the rule specified. The COPY command provides a convenient way to replace one rule with another or to fill in an empty template.
Issue the COPY command as shown:
RULE EDITOR ===> COPY DEPARTMENTS<Enter>
The contents of the current EMPLOYEES_RAISE rule are replaced with a copy of the DEPARTMENTS rule, as shown in the following screen:

 
RULE EDITOR ===> SCROLL: P
EMPLOYEES_RAISE;
_
_ ---------------------------------------------------------------------------
_ ------------------------------------------------------------+--------------
_ FORALL DEPARTMENTS : | 1
_ FORALL EMPLOYEES WHERE REGION = 'EDUC' & DEPTNO = |
_ DEPARTMENTS.DEPTNO : |
_ CALL MSGLOG('LAST NAME = ' || EMPLOYEES.LNAME || |
_ ' DEPARTMENT = ' || DEPARTMENTS.DEPTNO); |
_ END; |
_ END; |
_ ---------------------------------------------------------------------------
 
PFKEYS: 1=HELP 3=END 12=CANCEL 13=PRINT 14=EXPAND 2=DOCUMENT 22=DELETE

 
If you change the name of the rule that you are editing (without making other changes) and if there is no rule with the new name in your local library, the Rule Editor creates a copy of the original rule under the new name. If a rule with the new name already exists, you are prompted to overwrite it.
DELETE Command (PF22)
The primary command DELETE deletes a rule from your local library. To issue the command, type DELETE in the primary command field, or display the rule and press PF22.
The Rule Editor does not delete a rule without first prompting you to type the command CONFIRM or press PF22 to confirm the deletion. To cancel the deletion, press Enter or any other function key.
DOCUMENT Command (PF2)
The primary command DOCUMENT causes a screen to appear where you document the description and usage of your rule. To issue the command, type DOCUMENT in the primary command field, or display the rule and then press PF2.
See Also
TIBCO Object Service Broker Getting Started about documenting rules and other TIBCO Object Service Broker objects.
EDIT Command
You can use the primary command EDIT to edit a different rule or to create a new rule from within an editing session. The rule being edited is checked for syntax errors, and when it can be saved the new editing session begins.
Editing a Different Rule
To edit a different rule from within an editing session, type the EDIT command and the name of the required rule in the primary command field, and press Enter. For example, if you are editing the EMPLOYEES_RAISE rule and you want to edit the DEPARTMENTS rule, type the EDIT command as shown:
RULE EDITOR ===> EDIT DEPARTMENTS<Enter>
If there are no syntax errors, the Rule Editor saves the EMPLOYEES_RAISE rule before it displays the DEPARTMENTS rule. If there are syntax errors, you must correct them before the Rule Editor can begin the editing session for the DEPARTMENTS rule.
Creating a New Rule
To create a new rule from within an editing session, type the EDIT command and the name of the new rule in the primary command field and press Enter.
END Command (PF3)
You can end the editing session and save the changes by typing END in the primary command field and pressing Enter, or by pressing PF3. If there are no syntax errors, when you issue the END command the Rule Editor saves the rule in the local library you are using, not in the library of origin, and returns you to the workbench. You must correct your syntax errors before the rule can be saved. Refer to Syntax Checking Performed on a Rule for more information.
FIND Command
To find a particular token, use the primary command FIND. Type in the FIND command as follows:
RULE EDITOR ===> FIND search_token<Enter>
Usage Notes
The search for the token begins immediately to the right of the cursor position (not at the beginning of the rule) and, if successful, positions the cursor at the start of the first occurrence of the token. Use PF5 to continue the search from the current cursor position. Use PF6 to change the current occurrence to a null value.
If the search is unsuccessful, a message appears on the message line informing you that the search is unsuccessful. This means that the search failed to find an occurrence of the token between the current cursor position and the end of the rule. Use PF5 to resume the search from the beginning of the rule.
HELP Command (PF1)
You can display online help by typing HELP in the primary command field or by pressing PF1. The online help contains a description of the Rule Editor and a list of the Rule Editor commands and their syntax. To return to the rule, press PF3 or PF12.
LOWER Command
You can use the primary command LOWER to type string literals in mixed case (that is, text within single quotation marks). If you are editing an existing rule, you must issue the primary command LOWER and press Enter before the lowercase text is typed in. Existing lowercase text remains in lowercase when it is edited.
PRINT Command (PF13)
To print the current rule, press PF13 or type PRINT in the primary command field and press Enter. The hardcopy output includes some of the documentation for the rule. The documentation that is included appears between the rule definition and the conditions.
SAVE Command
Rules are not actually updated in your local library until you save your changes. You can save changes by typing SAVE in the primary command field and pressing Enter. The Rule Editor saves the rule in the local library you are using, not in the library of origin, and continues the editing session.
If the Rule Editor cannot save a rule, it gives a reason for the failure on the message line and positions the cursor where the first correction is required. You must correct the rule before you can save the changes. Refer to Syntax Checking Performed on a Rule for more information.
UPPER Command
If you issue the primary command LOWER and you want to revert back to using uppercase for your string literals, type UPPER in the primary command field and press Enter.
XEDIT Command
You use the XEDIT command to edit an existing or new rule within an editing session. The difference between EDIT and XEDIT is that XEDIT cancels changes made to the rule currently being edited.
To cancel editing changes made to EMPLOYEES_RAISE and start editing the DEPARTMENTS rule, type the XEDIT command as shown:
RULE EDITOR ===> XEDIT DEPARTMENTS<Enter>
Redisplay the Most Recent Primary Command–(PF9)
The Rule Editor stores a command until it is replaced with another command. PF9 redisplays the most recent command, which you can edit if necessary. For example, suppose that the previous command was the following:
RULE EDITOR ===> CHANGE REGION LOCATION ALL<Enter>
You now want to change the token DEPT to the token DEPARTMENT#. Re-display the previous command by pressing PF9. Place the cursor where editing is required (on the token REGION) and alter the command by overtyping, as follows:
RULE EDITOR ===> CHANGE DEPT DEPARTMENT# ALL<Enter>

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved