Advantages of the Block Operation (Magic xpa 4.x)
The Block operation encloses a group of procedural operations into a logical block, so that all the operations within the block are dependent on one condition, which is the Block operation condition.
Using the Block operation has several advantages:
-
As a developer, it saves you time since you can set a condition once for several operations, instead of setting the condition for each of the operations separately. In addition, it makes the maintenance of the program easier. If you need to change the condition, you only need to change it once in the Block operation.
-
For the engine, it saves multiple checks when several operations depend on the same condition. When you use the Block operation, the engine checks the condition only once when it gets to the Block operation and not every time it gets to each of the operations.
-
Using the Block operation enables you as a developer to simplify the expressions. You can divide complex expressions into several logical sections and set each of them as the condition of a Block operation.
For example If you want to set a verify warning if: Country='ITALY' and City='MILAN', you can use:
Block If (Cnd = Country='ITALY')
Block If (Cnd City='MILAN')
Verify
Block End
Block End
-
The Block operation enables you to nest operations. If you need to execute several operations under a certain condition and then, some of the operations need to be executed under another condition, you can use a Block operation with a condition and within it use another Block operation with another condition. In this case all the operations within the embedded Block will be executed only if both of the Block conditions are met.
In the above example, the Verify operation will be executed only if: Country='ITALY' and City='MILAN'.