This topic explains how to use CpExtra command variables to set up and execute actions in Captivate HTML5 output.
Before reading this page, please make sure you have familiarized yourself with CpExtra's basic concepts.
How To Create A Command Variable
- Identify the command variable you wish to create. Each command variable is tied to only one name, you'll need to know that name of the command variable before you can create it.
- On the menu bar, go to Project > Variables... this opens the Variables dialog.
- Click Add New
- In the Name field, type the variable's name. The variable name is case sensitive. (Note: If you want the command variable to sort to the top of the variable's list, then you can put an underscore in front of its name. _xcmndHide will work exactly the same as xcmndHide)
- Click Save. The command variable has successfully been created.
You do not need to give command variables default values, they will be ignored. In fact, if you ever read a Command Variable's value, it will always come back as 0.
Command variables should never be used to save a value. They should only ever be used to perform actions.
What Can Command Variables Do?
All sorts of things.
Currently they break down into the following categories.
- Extensions of captivate's default actions
- Mouse related actions
- Event and advanced action related actions
- Variable related actions
- Slide object positioning
- Mathematic operations
- Various other uses
Click the links above to see specific instructions on how to use those variables.
How To Use Command Variables
Command variables perform actions based on whatever value you assign to them. Many command variables require multiple items of information in order to operate. These separate items of information are called "Parameters". It is highly recommended you read the help on how to use parameters before starting to use command variables.
There are only two places in Captivate where you can assign a value to a variable. Therefore any place in Captivate where you can change the value of a variable allows you to enact a command variable. These are the following places.
Fulfilling an Interactive Object's Criteria
Interactive Objects (These are: Buttons, Click Boxes, Text Entry Boxes, some Widgets, or Smart Shapes designated to be used as Buttons) allow you to trigger actions when a certain criteria is met.
These settings are configured under the Actions sub-menu.
For example, for a Button, the success criteria is met when you click the button. If you turn off Infinite Attempts, the button will then have a last attempt criteria, which is met if you click anything other than the button.
You can choose from a list what action should be taken when any of these criterias are met. One of those actions is called Assign.
The Assign action allows you to change a variable's value. When you assign to a command variable a value it can understand, it will then take action.
It is therefore very easy to enact a command variable's action when clicking on a button.
On Slide Enter / Exit
Much like above, you can also choose specific actions that can take place when entering and exiting a slide. This is done in the following way:
- Go to the slide you wish to perform the enter / exit action on.
- Open the Properties panel.
- Make sure nothing is selected on slide.
- Go to the Actions submenu.
- There you will see an On Enter and On Exit drop down menu.
From those drop down menus you can also pick the Assign action to change a command variable's value.
On Answering a Quiz Question / Drag and Drop Interaction
You can also take certain actions on correctly or incorrectly answering a quiz question of drag and drop question.
- Go to a quiz slide.
- Open the Quiz panel.
- Scroll down to the Actions section.
- There you will see the On Success and Last Attempt drop down menus.
Once again, from here you can pick the Assign action.
Drag and Drop Interactions
- Go to a slide with a drag and drop interaction.
- Open the Drag and Drop panel
- There you will see the On Success and On Failure drop down menus.
The Assign action is available here also.
In an Advanced Action
If you are looking to do anything more than a simple interaction, then you're probably going to want to call a succession of actions, rather than just one.
This is achieved by using Advanced Actions. They are created by going to Project > Advanced Actions.
From there you can use the Assign action (or potentially even use the Expression action) to send a value to a command variable.
For more information about using Advanced Actions, check out our course about them here.
For example, you want to hide a caption on slide called MyCaption. That can be done by assigning the string MyCaption to xcmndHide.
xcmndHide = "MyCaption";