Set Variable to Expression Action

image\Action_Variable_Set_Expression.jpg

The Set Variable to Expression is very similar to the Set Variable action, in that it lets you:

(i) Create a new variable and tell the publication it is now available for use and to give it a value at that point.

(ii) Change the value of a variable that already exists.

However, there are two differences between the two actions:

(i) The Set Variable to Expression uses an OpusScript expression to create the contents of the variable.

(ii) The expression can include variables created in Opus and variables created within an OpusScript program.

Note:
Variables store information while the user is running a publication. If you want to store the contents of a variable permanently on the user’s computer you will have to write them to the disk – see Write to Disk File action for more information

Setting up the Variable to Expression action:

1. Add the Set Variable to Expression action to your trigger, as described in adding actions. The Set Variable to Expression tab will automatically appear when you add the action.

2. Use the Variable box to select the variable that you want to set (i.e. which variable you want to change the value of). Click on the down arrow to the right of the Variable box to list all of the variables in the current publication. Alternative, click on the New… button to open the New Variable dialog box in which you can create a new variable.

Note:
The variables are listed in alphabetical order. You can only set (i.e. change) one variable with each Set Variable to Expression action.

3. Use the Editor window under the Set this variable to the following… panel to type in the OpusScript expression. Click inside the Editor window to begin typing and press the Enter key on the keyboard to insert a new line in the window.

Note:
Below the Editor window is an Error Message Line – if the expression entered in the window is syntactically correct the message will read Expression OK; if the message reads Expression contains errors, then at least one line of code in the editor is syntactically incorrect i.e. it is not a valid OpusScript statement

4. Use the Overwrite current contents option when you want to entirely replace the current value of a variable with the new value you entered in the Editor window. By default, this option is selected. The old value for this variable is lost.

5. Use the Add to existing contents if you want to append to the end of the current value of the variable you selected in the Variable box (see point 2 above).

6. Click on the Apply button to save your changes.

Note:
As well as the Set Variable to Expression action, Opus provides an action: to set the value of a variable to any text, number or value of another variable; and to set the values of a variable array – see Set Variable and Set Variable Array for more information.

Related Topics:

Introducing the Variables Actions

Choosing an Action