Command Reference - Action Examples
In this example, we'll tell the user what item they selected in a List Box Object by changing the text in a Text Object on the same page. We'll set up the List Box Object in advance with three items in it: "One", "Two" and "Three". We'll put all of our actions on the "On Selection Changed" event for the List Box Object, so they will be performed whenever the user selects any of the items.
Here's what the action list looks like:

First, we use a "List Box Object - Get Selected" action to find out what item (or items) the user has selected. The "List Box Object - Get Selected" action returns a double-semicolon (;;) delimited list of indexes, with one index for each item the user currently has selected.

If the user has the first two items selected, the action will store "0;;1" in the variable %SelectedIndex%. (List box indexes are zero-based.)
If the user has only the first item selected, the action will store "0" in %SelectedIndex% instead.
Next, we use a "String - Count Delimited Strings" action to find out how many items are selected.

This will count the number of items in the delimited list, and store the count in a variable called %SelectedCount%. Since there is one string in the delimited list for every item that was selected, this is the same as counting the number of items that were selected.
Next, we use a "Control Structure - IF" action to determine whether the user has more than one item selected in the list box.

(This makes it so the actions inside the IF block will only be performed if the number of items selected was greater than 1.)
If the user has more than one item selected in our list box, we want to display a message telling them so. We'll do this by changing the text in a Text Object with a "Text Object - Set Text" action.

Note that "MouseOverText" is just the name we gave to the text object whose text we're setting.
Now, the rest of our action list is meant for when the user has only one item selected. We don't want AutoPlay Media Studio performing these actions when the user has multiple items selected, so we'll use a "Control Structure - RETURN" action to end the action list immediately at the bottom of this IF block.
If there is only one item selected in our list box, %SelectedCount% won't be greater than 1, and the actions in this IF block—including the "Control Structure - RETURN" action—won't be performed.
|
NOTE |
|
|
|
|
|
We're able to use a RETURN in this case because there isn't anything else in the action list that we want performed when multiple items are selected. If there was something else in the action list that needed to happen when multiple items are selected, we would use a "Control Structure - GOTO" action to jump over the single-item actions instead. |
The rest of the action list consists of three more IF blocks, each one testing for a specific case (the first item, second item, or third item selected) and setting the Text Object's text appropriately.
Here's a link to the finished example, as an AutoPlay Media Studio 4.0 page that you can import into your own project: