52.9.2 If–Else Constructs

An if–else construct is used to split the execution flow into several branches based on the outcome of a previous activity.
Here is an example. Suppose the device is on a WCDMA network and is instructed to do an FTP download. Now if the device is handed over to GSM, so that the throughput is sharply reduced, then we want to abandon the download, i.e. the activity should terminate. (This is accomplished by imposing a "terminate on event" condition on the activity; see section "Activity Properties That Control Execution".) After a handover to GSM has occurred, we want to proceed with a voice call (which does not require a large bandwidth). If on the other hand the device remains on WCDMA, then after the FTP download has completed we want to continue with a video streaming session.
To this end we use an if–else construct in the following manner:

First add a "Network Connect" activity, and then an "FTP Download" activity with the Abort property set to On Event and "Handover from UTRAN" selected as event type:

Then add an "If–Else" activity below the FTP download:

For the left-hand branch ("ifElseBranchActivity1"), set Condition Type to Activity Result, and set the associated attributes as follows: Activity = the name of the FTP download activity, by default "ftpDownloadActivity1", Operator = Equals, Result = Stopped by Event. See next screenshot.

For the right-hand branch ("ifElseBranchActivity2"), set Condition Type to Any. This always evaluates to true, so that the right-hand branch will be executed whenever the condition in the left-hand branch is false. (Not shown in the screenshot below.)

Add a voice dial activity on the left (to the node "sequenceActivity1") and a streaming activity on the right (to the node "sequenceActivity2"), as described in the introduction of this subsection. This is done just as in sections "Basics of Creating Scripts (with Voice)" and "Setting Up a Data Service Activity" and is not detailed here.

See section "If–Else" for full details on the If–Else activity.