Navigation:  More Advanced Procedures > Using Variables >

User-defined variables

Print this Topic Previous pageReturn to chapter overviewNext page
Show/Hide Hidden Text

You can define any number of your own variables to use in your project. These user-defined variables are stored with your project, which means that they are only available to the project in which they are defined. However, you can transfer variables between projects with the Export and Import functions (see below).

User-defined variables can be used almost everywhere in your projects: In topics and headers, the Table of Contents, keywords, image captions, link captions, macros, scripts, HTML code objects, HTML templates and PDF templates. See the other topics in this section for details on using variables in these locations.

See Inserting variables in topics and Inserting variables in other locations for details on how to use variables in your projects.

Plain-text variables and HTML variables

You can define two different types of variables: Text variables and HTML variables. Both types have no effective length limit (theoretically you could enter up to 2 gigabytes of text).  See The power of editable variables for more details on using HTML variables.

Plain-text variables:

Plain-text variables contain text only. The text is inserted as plain text wherever you use the variable. You can use them anywhere where variables are supported.

HTML variables:

HTML variables contain HTML code. They are designed primarily for use in HTML templates and HTML code objects. If you use an HTML variable anywhere else (for example in a topic in the Help & Manual editor) only the text portion of the variable value will be inserted. If there is no text portion nothing will be inserted.

How to define a variable
1.In the Project Manager go to Configuration > Common Properties > Text Variables.
2.Select Add, enter the name for your variable and click on OK.

You don't need to worry about case, the variable name will be converted to all upper case automatically.

3.Select HTML or Text in the Type column. HTML Variables can contain HTML, JavaScript and CSS code in addition to normal text.
4.If you want to protect the variable against accidental editing select Yes in the Protected column. The values of protected variables are shown grayed out.
5.Click in the Value column next to your new variable and enter the text or HTML code.

There is effectively no limit to the amount of text you can enter you are unlikely to be able to enter more than 2 gigabytes of text in the Value column!

Variable name syntax

Exactly the same variable name syntax is used for variables in all parts of your projects:

<%VARIABLENAME%>

Since you can also type variables manually in topic text and topic headers it is important to observe this syntax! The variable name VARIABLENAME must be in all upper case and it must be enclosed between opening and closing <% and %> tags.
Spaces are allowed in variable names because the beginning and end of the variable are clearly defined by the <% and %> tags. For example:

<%VARIABLE NAME WITH SPACES%>

How to edit user-defined variables
In the Project Manager go to Configuration > Common Properties > Text Variables.

OR:

Double-click on a variable in the editor and select More... to go the Text Variables configuration screen.

The second option only works with variables entered with Insert > Text Variable. Variables typed in manually are not highlighted and you cannot display the variables list by double-clicking on them.

Importing and exporting your user-defined variables

You can use these features to copy variables between projects and to define variables in a text editor and then load them into your project. (This can be easier than defining a lot of long variables directly in Help & Manual.)

Exporting user-defined variables:

1.In the Project Manager go to Configuration > Common Properties > Text Variables.
2.Select to Export your project variables to a text file.

Importing user-defined variables from a file:

1.Use an editor like Windows Notepad to create a list of variables in a plain text file, using the following syntax:

VARIABLENAME1=Variable value
MYVARIABLE=another variable value

One variable per line, variable name all in capital letters, no spaces on either side of the = character, no quotes. You can also enter HTML code for HTML variables, of course.

2.Import the variables with the Import button in the Text Variables section in your Project Configuration.
3.If your list includes HTML variables you must manually change the type of the variables to HTML after importing, otherwise the code will be interpreted as plain text.

Use the Export function (see above) to see an example of the necessary format and the syntax of the file.

Importing user-defined variables from another project:

You can also import all the user-defined variables from another Help & Manual project. To do this just click on Copy properties from... at the bottom of the Text Variables editing window and select the project you want to import the variables from. This will overwrite the variables in the current project.

If you want to merge the variables from another project you must export them to a text file and then import them from the text file  (see above).

See also:

Variables and Conditional Output (Reference)

 


Page url: http://www.helpandmanual.com/help/index.html?hm_working_variables_userdef.htm