-
Notifications
You must be signed in to change notification settings - Fork 0
A conditional group of single line actions
In the example below, the line with the ? consists of single decision action. On a data flow diagram this would just be a bubble outputting mutually exclusive control flows. In Scrall, a variable is set and tested. An empty instance set variable evaluates as false, a table variable with zero rows/tuples evaluates as false, a false boolean variable will, of course, evaluate as false. A scalar type, on the other hand, must be explicitly tested to evaluate as false since its structure is opaque to our relational world.
Below that first decision action, an expression is evaluated to decide which block of actions to execute. The second action block is enclosed in {} brackets and spread across multiple lines.
cabin in shaft .= /R2/Cabin
xfer .= cabin in shaft/R53/Transfer
call in progress .= xfer/R49/Floor Service( Direction: cabin in shaft.Travel direction )
fwd dest .= cabin in shaft.Ping( dir: cabin in shaft.Travel direction )
fwd dest? destination aslev .= fwd dest :
!call in progress? {
// Search opposite the travel direction only if not servicing
// a floor request in the current direction
rev dest .= cabin in shaft.Ping( dir: Travel direction.opposite() )
rev dest? cabin in shaft.Travel direction.toggle()
destination aslev .= rev dest // may be empty
}
This example is an excerpt from the R53 assigner state model in the Elevator 3 Case Study. Its purpose is to search for a destination ahead of the Cabin in its current travel direction and, if none is found and there is no active floor call request (arrow button at floor), search behind the Cabin for a destination.
After attempting to select a forward destination, fwd dest, the value is checked and, if a destination was found it is saved as destination aslev. Otherwise, if no call in porgress was detected the bracketed action block, which looks in the opposite direction, is executed.
See the section on Conditional Execution under Control Flow for more about conditional processing.
Copyright 2020, 2021, 2022, 2023, 2025 © Leon Starr under MIT Open Source License
- Why they are problematic
- Instance attribute creation values
- Boolean values
- Special values
- Enumerated values
- Action block
- Statement
- Single line action
- Multiple dependent actions on a single line
- An action spread across multiple lines
- A conditional group of single line actions
- Comments
- Finding instances
- Attribute access
- Creation and deletion
- Subclass migration
- Creating a table from a class
- Creating a table with a definition
- Converting a table into a class
- Set operations on tables
- Set comparisons on tables
- Join
- Rename
- Extend
- Aggregation
- Rank
- Image
- Input values
- Signatures and name doubling
- Output values
- Execution order
- Sequential execution
- Conditional execution
- Signals
- Scrall has no for_each action
- Iteration