This is a very powerful block which acts as a placeholder that chooses one block from a set of possibilities based on information available at the time the block is created.
The process for selecting the block is straightforward: The result of the Match Expression is compared against the result of each Match Value expression in the order in which they are defined.
A match is is defined as an exactly, textual equivalence between the results of the two expressions.
- If a match is found, the corresponding block is created and used in place of this block.
- If a match is not found, the Default Block is used instead.
- If this block is refreshed, the expressions are re-evaluated and the selection is performed again.
Example: Play / Pause
This block can be used effectively to change the presentation of a view based on the content in a data source, or change a view's presentation by setting a variable and executing a block refresh in a script.
A classic, very useful example is a Play / Pause Controller.
If you want to develop any sort of music playing app you need a the very least of Play / Pause function.
This is implemented in the Selector Tutorial App.
That state is kept through a variable (PlayPause) and the app refreshes the button according to the last pressed using a selector which check the state PlayPause variable to do so.
An implementation using that Selector is the RADIO demo app which let user select among different radio stations.
This 4.00 version includes whitespace, so care should be used to make sure there are no inconsistent spaces, linefeeds or tabs in the expressions.
If you change the variable being tested, make sure to refresh the Block