You can modify the value of a variable during the runtime of a published title. The Modify Variable action enables you to replace, round, add to, subtract from, multiply and divide variable values. All variables can be accessed from anywhere within your title, so this action can be added to any location within your title.
To modify a variable value:
Add an action to your title and select Modify Variable from the Action list in the Action and Target group on the Action ribbon. For details about adding an action see Adding an action.
Select the target variable name from the Target list. This is the variable whose value you want to modify. It can be a string-valued variable (containing non-numeric characters) or a number-valued variable (containing only numeric characters). If you have not created the variable you want to modify, click the New Variable submenu item on the Target list and add a new variable. For details, see Creating a variable.
Select how you want to modify the variable from the Type list. Choose from the following:
Add to Variable |
For number-valued variables, this will result in the mathematical addition of the target variable's value and the value specified in the Value field. For example, if the target variable's value is 3 and the value specified in the Value field is 2, the resulting value of the target variable is 5. For string-valued variables, this will result in the joining of the target variable's value and the value specified in the Value field. For example, if the target variable's value is Hello and the value specified in the Value field is World, the resulting value of the target variable is HelloWorld. |
Divide Variable by |
This modification type is only applicable for number-valued variables. It will result in the mathematical division of the target variable's value by the value specified in the Value field. For example, if the target variable's value is 21 and the value specified in the Value field is 7, the resulting value of the target variable is 3. |
Multiply Variable by |
This modification type is only applicable for number-valued variables. It will result in the mathematical multiplication of the target variable's value and the value specified in the Value field. For example, if the target variable's value is 3 and the value specified in the Value field is 7, the resulting value of the target variable is 21. |
Round Down Variable |
This modification type is only applicable for number-valued variables. It will result in the target variable's value being replaced by the greatest whole number lower than its current value. For example, if the target variable's value is 3.75, the resulting value of the target variable is 3. |
Round Variable |
This modification type is only applicable for number-valued variables. It will result in the target variable's value being replaced by the nearest whole number greater or lower than its current value. For example, if the target variable's value is greater than or equal to 3.5 and less than 4, the resulting value of the target variable is 4. If the target variable's value is less than 3.5 but greater than 3, the resulting value of the target variable is 3. |
Set Variable Contents |
This modification type will replace the current value of the target value with the value specified in the Value field. |
Subtract from Variable |
For number-valued variables, this will result in the mathematical subtraction of the value that you specify in the Value field from the target variable's value. For example, if the target variable's value is 5 and the value specified in the Value field is 3, the resulting value of the target variable is 2. For string-valued variables, this will result in the removal of all instances of the value that you specify in the Value field from the target variable's value. For example, if the target variable's value is ABACAB and the value specified in the Value field is A, the resulting value of the target variable is BCB. |
When necessary, specify the value in the Value field by which you want to modify the target variable's value. You can directly specify a value, select a random number or specify the value of an existing variable. To select a random number, enter RAND(min, max) in the Value field. The random number assigned will be greater than or equal to the min value specified and less than or equal to the max value specified. The random number generated will be used to modify the Target variable. To specify the value of an existing variable, enter VAR(Variable_Name) in the Value field. The Variable_Name is the name of the variable whose value should be used to modify the Target variable.
When you have completed defining your action, you can preview the functionality of the action within your title by clicking the Run Mode or Preview Mode toolbar graphic on the Mode bar. You can also preview the functionality of the action within your title by clicking the Debug Mode toolbar graphic on the View ribbon. This will also launch the Debug Window, which will display when the action was fired and any variable manipulations that occur with the action.
See also: Switching between modes
© Copyright eLearning Brothers 2021