How to Use Variables in Your Help Project
HelpSmith provides support for variables that you can use in your help files and documents. The variables are divided into system variables (for example, #HelpTitle, #Copyright, #Date, #Time), and user-defined variables, which means that you can add any number of custom variables to your help project and define values for them.
Using variables in your help project allows you to avoid the need to update repetitive data in each and every topic. For example, you can easily insert the current date, time, the title of your help project, product name, or product version into any place of the help project. When you compile your help project to create a CHM help file, Online Help system, or PDF document, the variables will be automatically replaced with their actual values.
Below are the instructions that you can use to view, edit, and insert variables into different places of your help project.
Where You Can Use Variables in Your Help Project
HelpSmith allows you to insert variables into different places in your help project, such as:
- The content of a help topic.
- The content of a topic template.
- Text fields in project options, topic properties, and other settings.
- The code of HTML insertions that you can embed into a topic.
- The code of HTML templates that you can use for the Web Help and ePub layouts.
View and Define Variables in Your Help Project
You can view and edit the variables of your help project as follows:
- On the Project tab, click Project Objects.
- In the popup menu, click Text Variables.
- In the Text Variables dialog, by clicking the buttons in the left sidebar, you can toggle between System Variables and User Variables.
- In the User Variables section, click the New button to define a custom variable and its value.
Insert a Variable into a Topic or Template
- In Project Manager, select the topic or template into which you want to insert a variable.
- In the word processor, put the text cursor where you want to insert a variable.
- On the Insert tab, in the Placeholders group, click Text Variable.
- In the popup menu, select the variable that you want to insert. Alternatively, you can click "Insert Text Variable" to select the variable via the Text Variables dialog.
Insert a Variable into a Text Field
To insert a variable into a text field (as shown in the video), you should use the following syntax:
For system variables, the syntax should be:
%#VariableName%
For example: The title of this help file is %#HelpTitle%.
For user-defined variables, the syntax should be:
%VariableName%
For example: The current product version is %ProductVersion%.
Insert a Variable into HTML Code
To insert a variable into the code of an HTML insertion, or HTML-based template, you should use the following syntax:
For system variables, the syntax should be:
<%#VariableName%>
For user-defined variables, the syntax should be:
<%VariableName%>