Example: Using a custom string variable in an agent
Use the Programming view to create custom variables in an agent using a numeric value. The steps in this section are for more advanced users of Composer Pro.
In this example, program Button 4 on a Keypad to toggle through four playlists.
Note: This procedure is relatively complicated to create. Review the steps first to understand how the conditionals work.
Prerequisites
The following items are added and identified in the project:
- Controller
- 6-Button Keypad
- 4 Playlists: Mom’s Favorites, Dad's Favorites, Choral Music, and Kid’s Music
To program using a custom variable agent string:
- Start Composer Pro and connect to a Director.
- Click System Design. Make sure the project has the correct devices and rooms.
- Click Connections. Make sure the connections are correct.
Note: In the Network tab, ensure that the controller and the 6-Button Keypad have an address.
Add a new variable
- Click Agents.
- Select Variables. The Variables agent list appears.
- Click New.
- On the dialog that appears, do the following:
- Select New Variable, and name the variable My Playlists.
- In Variable Type, use the pull-down menu to select String, and click OK.
Set up a ‘Mom's Favorites’ playlist in the theater
- Click Programming.
- In Programming select the 6 Button Keypad in the Theater from the Device Events pane.
- In 6-Button Keypad Events, click Button 4 on the Keypad.
- In the Device Actions pane, scroll down and click to expand Variables.
- Select My Playlists.
- In the My Playlists Actions pane, click the Conditionals tab, and enter the name of a playlist; for example, Mom’s Favorites.
- Drag the first blue question mark to the Script pane.
- In Device Actions, select the Theater room object.
- In Theater Actions, select Select Media.
- In the window that pops up, select Playlists, Mom’s Favorites, and then click OK.
- Drag the green arrow icon on top of the first blue question mark in the Script pane to make it the first subset of the first conditional.
- In Device Actions, select Variables > My Playlists.
- In the Commands tab under My Playlists, enter the name of the next playlist that you’d like to play; for example, Dad’s Favorites.
- Drag the green arrow on top of the first blue question mark to the Script pane to make it a second subset of the first conditional.
The next time the button on the keypad is pressed, the value of the variable will be Dad’s Favorites, and will then cue that playlist in the Theater.
- In Device Actions, scroll up and select the 6 Button Keypad in the Theater.
- In 6 Button Keypad Actions, click Button 4.
- Under Color Settings select LED On.
- Click the square of color to select the color you want Button 4’s LED to be when Mom’s Favorites plays. Select the color in the menu that pops up (in this example: green), and click OK.
- Drag the green arrow on top of the first blue question mark in the Script pane to make it a third subset of the first conditional.
- In Device Actions, scroll down and select Programming Control.
- In the Programming Control Actions, select the Stop radio button.
- Drag the green arrow on top of the first blue question mark in the Script pane to make it a fourth subset of the first conditional.
Note: It is important to add a Stop command here so that when the conditional is fulfilled, the programming will not continue. Because of the way this programming is set up when it’s finished, without the stop, the button on the Keypad will always select the last playlist in the script.
Set up a ‘Dad's Favorites’ playlist
- In Device Actions, select My Playlists again.
- In the Conditionals tab, next to ‘Is’ enter Dad’s Favorites in the text box.
- Drag the second blue question mark to the Script pane.
- In Device Actions, select the Theater.
- In Theater Actions, select Select Media.
- In the window that pops up, select Playlists, Dad’s Favorites, and then click OK.
- Drag the green arrow on top of the second blue question mark in the Script pane to make it the first subset of the second conditional.
Set up a ‘Kid's Room’ playlist
- In Device Actions, select My Playlists.
- In the Commands tab under My Playlist Actions, enter the name of the next playlist that you’d like to play; for example, Kid’s Music.
- Drag the green arrow on top of the second blue question mark in the Script pane to make it a second subset of the second conditional.
- In Device Actions, select the 6 Button Keypad in the Theater.
- In 6 Button Keypad Actions, click on Button 4. Click the square of color to select the color you want Button 4’s LED to be when Kid’s Music plays. Select the color in the menu that pops up (in this example: purple), and click OK.
- Drag the green arrow on top of the second blue question mark in the Script pane to make it a third subset of the second conditional.
- In Device Actions, select Programming Control.
- In the Programming Control Actions pane, select Stop.
- Drag the green arrow on top of the second blue question mark to make it a fourth subset of the second conditional.
- In Device Actions, select My Playlists again.
- In the Conditionals tab, enter Kid’s Music.
- Drag the blue question mark to the Script pane to make it the third conditional.
- In Device Actions, select the Theater room object.
- In Theater Actions, select Select Media.
- In the window that pops up, select Playlists, Kid’s Music, and then click OK.
- Drag the green arrow on top of the third blue question mark in the Script pane to make it the first subset of the third conditional.
Set up a ‘Choral Music’ playlist
- In Device Actions, select My Playlists.
- In the Commands tab under My Playlists, enter the name of the next playlist that you’d like to play; for example, Choral Music.
- Drag the green arrow on top of the third blue question mark to make it a second subset item of the third conditional.
- In Device Actions, select the 6 Button Keypad in the Theater.
- In 6 Button Keypad Actions, click on Button 4. Click the square of color to select the color you want button 4’s LED to be when Kid's Music plays. Select the color in the menu that pops up (in this example: red), and click OK.
- Drag the green arrow on top of the third blue question mark in the Script pane to make it the third subset of the third conditional.
- In Device Actions, select Programming Control.
- In the Programming Control Actions, select the Stop radio button.
- Drag the green arrow on top of the third blue question mark in the Script pane to make it a fourth subset of the third conditional.
- In Device Actions, select My Playlists again.
- In the Conditionals tab, enter Choral Music.
- Drag the fourth blue question mark to the Script pane.
- In Device Actions, select the Theater room object.
- In Theater Actions, select the Select Media radio button.
- In the window that pops up, select Playlists, Choral Music, and then click OK.
- Drag the green arrow on top of the fourth blue question mark in the Script pane to make it the first subset of the fourth conditional.
- In Device Actions, select My Playlists.
- In the Commands tab under My Playlists, enter the name of the next playlist that you’d like to play; for example, Mom’s Favorites.
- Drag the green arrow on top of the fourth blue question mark in the Script pane to make it a second subset of the fourth conditional.
- In Device Actions, select the 6 Button Keypad in the Theater.
- In 6 Button Keypad Actions, click on Button 4.
- Click the square of color to select the color you want Button 4’s LED to be when Choral Music plays. Select the color in the menu that pops up (in this example: yellow), and click OK.
- Drag the green arrow on top of the fourth blue question mark to make it a third subset of the fourth conditional.
- In Device Actions, select Programming Control.
- In the Programming Control Actions, select the Stop radio button.
- Drag the green arrow on top of the fourth blue question mark to make it a fourth subset of the fourth conditional.
- In Device Actions, select the Theater room.
- In Theater Actions, select Media.
- In the window that pops up, select Playlists, Mom’s Favorites, and then click OK.
Note: You do this is because the first time the button on the Keypad is pushed, the string variable does not have a value, and nothing happens. This last command is created when none of the conditionals are fulfilled, something will play; each time the button is pushed thereafter, a conditional is fulfilled.
- Drag the green arrow below the previous Stop command in the Script pane. It is not a subset of the previous conditionals, but a command on its own.
- In Device Actions, select My Playlists.
- In the Commands tab under My Playlists, enter the name of the next playlist that you’d like to play; for example, Dad’s Favorites.
- Drag the green arrow below the previous command in the Script pane.
- In Device Actions, select the 6 Button Keypad in the Theater.
- In 6 Button Keypad Actions, click on Button 4. Click the square of color to select the color you want Button 4’s LED to be when Mom’s Favorites plays. Select the color in the menu that pops up (in this example: green), and click OK.
- Drag the green arrow below the previous command in the Script pane. You do not need a stop at this point, because the programming automatically stops at the end of the script.
Results: Press Button 4 on a 6-Button Keypad repeatedly to toggle through four playlists.