In This Topic
How can we search an export file for several different types of line? For example we might want to list all the cabinet codes in a library along with their descriptions. If we create a filter which looks for a Name equal to "code" and another which looks for a Name equal to "desc" then we will end up with nothing. This is because filters are effectively joined with an
AND which means we will be looking for any Name which equals both "code"
and "desc", which obviously can't happen. What we need is an
OR operator, so we can say "where Name equals "code"
or "desc"".
One simple way is to create a script with only one of the filters in it and run it. Then start a new script with the other filter in it, run it and then append the two merge files together. This will effectively result in a big
OR between the two sets.
A better way is to write a single script with an
OR in it. Create the two filters as you normally would, then create three "Script Branching" actions, one of each type - Begin, OR and End. Use the arrow buttons to move the "Begin" to the top of the script, and the "End" action to the bottom. Place the "OR" in between our two filters. Actions can also be re-ordered by clicking an action in the list and then using the up and down arrows on your keyboard while holding the Shift key. You should end up with a script that looks like the one shown here. Running this script will produce an output file containing lines that start with either "code" or "desc".
Even though this example only contains two branches (possible paths) with one action each, an OR block can contain any number of branches each with any number of Filter or Replace actions. However, you cannot nest OR blocks (i.e., have an OR block inside the branch of another), but unusual situations requiring this can be overcome by merging the output files as mentioned above. The term "OR block" refers to the part of the script between a set of "Begin" and "End" actions.
When writing OR blocks it might help to keep these facts in mind:
- Actions are executed from the top to the bottom of the script as normal
- If a line fails a filter outside an OR block it is discarded immediately
- When an OR block is encountered, actions in the first branch are run in order as normal
- If a line fails a filter inside a branch of an OR block, execution skips straight to the next branch
- When a line successfully passes through a complete branch (i.e. matches all filters between a set of OR actions) it skips to the "End" action of the OR block
- If a line fails every branch of the OR block then it has not matched the block and is discarded