Displaying Variables on a Page

Often you will want to display the contents of a variable on the page to show the user the information it contains. For example, you may want to show them their total score for a quiz or welcome them by name to the publication (if they have entered the name previously in an Input Text object, of course). There are many other reasons why you would also want to show the value of a variable on the page and it is a very simple and straightforward process. However, please note that variables do not support Unicode.

Note:
You can show any type of variable on a page (i.e. System, Page, Publication, Array variables) However, variables created in OpusScript have to be treated differently so if you want a variable of your own to display we recommend you create a Publication Variable – see Types of Variables for more information.

Displaying variables on a Page:

  1. To display a variable on a page, first draw a Text object on the page.

  2. Right-click on the Text object to open the right-click menu and select the Insert Variable or Expression option – this will open the Insert Variable or Expression dialog – see Insert Variable or Expression dialog for a full description of the dialog.

  3. Use the Variable option if you want to display the value of a System, Publication or Page variable. Click on the down arrow in the box under this option to list the current variables in your publication. Select your variable, and then click on the OK button to close the Insert Variable dialog. The name of the variable will be displayed in the Text object surrounded by chevrons, for example, <User_Name>.

Note:
The variable list will show all System and Publication variables as well as Page variables for the current page the Text object is on. The Array variables are NOT in the list – see next point.

  1. Use the Constant Expression option to display the value of an Array or an OpusScript variable. Type an OpusScript expression in the box. Type your expression, then click on the OK button to close the Insert Variable dialog – see Constant Expression examples. The expression will be displayed in the Text object surrounded by chevrons, for example, <User_Name>.

  2. You can type plain text before and after the variable name, so that the variable is part of a larger body of text – see Text object example.

Note:
You can format the inserted variable in the Text object just like any other text.

IMPORTANT NOTE FOR FLASH PUBLICATIONS

To display a variable in Flash publications you must ensure the text object is set to Dynamic – see Opus Flex Text Properties in Planning Flex Publications.

  1. In the Opus Editor the Text object will show the name of the variable surrounded by chevrons. When you preview the publication or the user runs the publication, they will see the value of the variable i.e. the contents of the variable and not its name.

  2. If you want to change the variable or expression used in a Text object, double-click the variable or expression in the text box – this will re-open the Insert Variable or Expression dialog showing the current selection, make your changes as required.

Note:
You can also display the value of a variable in a Button object – just follow the instructions above.

Related Topics:

What are Variables?

Types of Variable

Creating Variables

Insert Variable or Expression Dialog

Creating Arrays in Opus

Preset and System Variables - Glossary