One of the easiest ways to make use of Adobe Captivate variables is to display their values in text captions, shapes, and Smart Shape objects at run-time. In the example below I show how this is done by inserting several display fields into a single text caption.
How to display project information
Let’s imagine your project needs to have the e-learning author’s name and contact information appear on a slide at run-time. Here’s how you could do that:
- Create a new blank project and open the File > Project Info… (This is quicker than navigating to the same dialog location using Edit > Preferences > Project > Information.)
- Type relevant information into the fields provided.
- On another slide in your project file, insert a text caption and some text to indicate the type of information it provides.
- Place your mouse cursor at the point in the text caption where you want to insert the variable display field.
- On the Properties tab > Format accordion, click the Insert Variable icon.
- When the Insert Variable dialog opens, change the Variable Type to System and from the Variables drop-down list select cpInfoAuthor as the variable to be inserted.
- Pay close attention to the default value shown in the Maximum length field. It has some serious gotchas!
Gotcha # 1: In earlier versions of Cp this field was set to 15 characters by default. This length is fine if all you are doing is displaying a number, identifier code, or slide name. But it’s usually too short to display personal names, company names, course names, etc. In Cp7 the default length has been increased to 50 characters, but you can change it to specify any length up to about 250 characters. So give careful thought to how much information you need to display and set the field length accordingly.Gotcha # 2: There is a bug in versions prior to Cp7 where if you happen to be inserting a number of variables one after another, the Maximum Length field randomly reverts to a value of 0. So be sure to take a moment to check this field before hitting the OK button.
Gotcha # 3: If you happen to guess wrong about the required number of characters to allow as the length of the display field, you cannot easily change it. You must delete the inserted field and re-insert another one to change the display length. So it’s usually wise to bet a little on the high side to be safe.
- Once you’re happy with the details of the inserted variable, click the OK button. Your variable will appear by name, surrounded by double dollar signs (e.g. $$cpInfoAuthor$$).
- Repeat the last few steps to insert any other variables in the same caption. It should then appear something like the example screenshot shown below.
- Publish your project to see how the variables are displayed in the caption. They should look something like the screenshot below.
Why not just type the variable name with $$ characters on either end?
Perhaps you’ve read throught the steps above and wondered if you can insert a variable into a caption or shape by just typing the variable name and adding $$ characters at the beginning and end. Yes you can.
However, while it may be slightly faster, the downside to this method it that it doesn’t allow you to set the number of characters for the maximum display length. It will just assign the default amount, which is only 15 characters for Cp versions 5 through to 6.1 and 50 characters for Cp7. The 15 character default was far too small, and even 50 characters will sometimes be insufficient.
So, call me a control freak, but I still prefer to insert variables via the dialog method and set the display length myself.
Overcoming dynamic text formatting issues
When you insert a variable into a caption or shape, don’t be surprised if you need to fiddle around with the formatting a bit before it all looks right at run-time. These formatting issues are due to the fact that normal caption text is ‘static text’ (because it doesn’t change at run-time) while variable display text is ‘dynamic text’ (because it can change depending on the current value of the variable being displayed). In Captivate’s published output, captions containing static text are actually converted into images. But since this means the text becomes an image too, this approach would not allow dynamic text to change on-the-fly at run-time. So, static and dynamic text strings are kept separate. The result can be certain inconsistencies in visual formatting.
For example, some early versions of Captivate did not allow dynamic text to be indented. If you applied indenting in Edit mode, the indenting disappeared at runtime. If you added variable text into the middle of a paragraph of static text in a caption, none of that text would honor the applied formatting. This often resulted in captions with text unattractively crammed into the top-left corner or positioned hard against the left side of the caption. There were also notable differences in the aliasing of the text. For example note the differences in the two run-time captions below from Cp 5.5.
The text in the caption above left is just typed in. The one on the right is displaying text supplied by a user variable. The workaround for such formatting issues is to place dynamic text inside a transparent caption positioned on a layer above another caption. This made it appear as if the underlying caption contained the dynamic text when in fact it was just acting as a background.
Fortunately, these issues have been steadily diminishing with each new version and it’s now quite difficult to tell static and dynamic text apart as you can see from the Cp7 examples shown below.
Hopefully one day, in some future Cp version, there will be no discernible differences at all.