Constraints are used in a railroad diagram to control progression through the diagram. Constraints consist of symbols and unique railroad diagram line paths. They include
-
Vertical bars
-
Percent signs
-
Right arrows
-
Required items
-
User-selected items
-
Loops
-
Bridges
A description of each item follows.
Vertical Bar
The vertical bar symbol (|) represents the end of a railroad diagram and indicates the command or statement can be followed by another command or statement.
── SECONDWORD ── ( ──<arithmetic expression>── ) ──────────────────────┤
Percent Sign
The percent sign (%) represents the end of a railroad diagram and indicates the command or statement must be on a line by itself.
── STOP ───────────────────────────────────────────────────────────────%
Right Arrow
The right arrow symbol (>)
-
Is used when the railroad diagram is too long to fit on one line and must continue on the next
-
Appears at the end of the first line, and again at the beginning of the next line
── SCALERIGHT ── ( ──<arithmetic expression>── , ──────────────────────► ►─<arithmetic expression>── ) ─────────────────────────────────────────┤
Required Item
A required item can be
-
A constant
-
A variable
-
Punctuation
If the path you are following contains a required item, you must enter the item in the command or statement; the required item cannot be omitted.
A required item appears on a horizontal line as a single entry or with other items. Required items can also exist on horizontal lines within alternate paths, or nested (lower-level) diagrams.
In the following example, the word EVENT is a required constant and <identifier> is a required variable:
── EVENT ──<identifier>────────────────────────────────────────────────┤
User-Selected Item
A user-selected item can be
-
A constant
-
A variable
-
Punctuation
User-selected items appear one below the other in a vertical list. You can choose any one of the items from the list. If the list also contains an empty path (solid line) preceeding the other items, none of the choices are required.
In the following railroad diagram, either the plus sign (+) or the minus sign (–) can be entered before the required variable <arithmetic expression>, or the symbols can be disregarded because the diagram also contains an empty path:
──┬─────┬─<arithmetic expression>──────────────────────────────────────┤ ├─ + ─┤ └─ ─ ─┘
Loop
A loop represents an item or a group of items that you can repeat. A loop can span all or part of a railroad diagram. It always consists of at least two horizontal lines, one following the other, connected on both sides by vertical lines. The top line is a right-to-left path that contains information about repeating the loop.
Some loops include a return character. A return character is a character—often a comma (,) or semicolon (;)—that is required before each repetition of a loop. If no return character is included, the items must be separated by one or more spaces.
┌◄────── ; ─────┐ ──┴─<field value>─┴────────────────────────────────────────────────────┤
Bridge
A loop can also include a bridge. A bridge is an integer enclosed in sloping lines (/ \) that
-
Shows the maximum number of times the loop can be repeated
-
Indicates the number of times you can cross that point in the diagram
The bridge can precede both the contents of the loop and the return character (if any) on the upper line of the loop.
Not all loops have bridges. Those that do not can be repeated any number of times until all valid entries have been used.
In the first bridge example, you can enter LINKAGE or RUNTIME no more than two times. In the second bridge example, you can enter LINKAGE or RUNTIME no more than three times.
┌◄──────── , ───────┐ ──┴─/2\─┬─ LINKAGE ─┬─┴────────────────────────────────────────────────┤ └─ RUNTIME ─┘
┌◄─/2\──────────┐ ──┴─┬─ LINKAGE ─┬─┴────────────────────────────────────────────────────┤ └─ RUNTIME ─┘
In some bridges an asterisk (*) follows the number. The asterisk means that you must cross that point in the diagram at least once. The maximum number of times that you can cross that point is indicated by the number in the bridge.
┌◄──────── , ────────┐ ──┴─┬─/2*\─ LINKAGE ─┬─┴───────────────────────────────────────────────┤ └─ RUNTIME ──────┘
In the previous bridge example, you must enter LINKAGE at least once but no more than twice, and you can enter RUNTIME any number of times.