Imagine you're trying to create some cool interactivity in Adobe Captivate where you will need to use Expression actions to concatenate (join together) various text strings and numbers. In some cases you need to insert spaces between words or numbers. But, after trying to concatenate strings using normal space characters (entered via the keyboard) you find that Captivate either truncates (removes) the extra space characters, or adds a 0 character instead of the space.
How can you trick Adobe Captivate into allowing you to use spaces when concatenating strings?
Techniques required to solve this interaction
You need to create a user variable that holds a non-breaking space and then using this special-purpose variable in your Expression actions whenever you need to insert spaces between chunks of text or numbers.
Most Captivate developers are unaware that Expression actions can be used to concatenate strings because in all the Adobe documentation you are only ever told it can do simple math equations such as addition, subtraction, multiplication and division. The fact that it wasn’t really intended to be used to concatenate text strings helps to explain Captivate’s odd behaviour of attempting to remove or replace space characters found at the beginning or end of text strings that you are trying to concatenate. It thinks the spaces don't belong in the 'equation'.
The workaround is to create a user variable that holds a non-breaking space and use this variable whenever you need to use spaces at the end of a piece of text that will be to be joined to another. A variable of this type is almost essential when using Expression actions to do string concatenation.
There are actually two main parts to this task. First, you need to copy a genuine non-breaking space character from somewhere. Second, you need to create a user variable and paste in your copied non-breaking space.
Part 1: Get a non-breaking space character.
- Open a project file and insert a text caption somewhere on a slide.
- Select all text within the text caption.
- In the Properties tab > Format accordion, click the Insert Symbol icon.
- When the Symbols dialog opens, click the Non-Breaking Space item. (The dialog will close immediately and you will find that the mouse cursor in your text caption is now sitting slightly to the right of the left end of the caption.)
Why not just use Ctrl + Shift + Space to insert?
You may notice that the screenshot of the Symbols dialog seems to indicate you should be able to use a keystroke (Ctrl + Shift + Space) to insert a non-breaking space. However, in practice I have never found this to be reliable. By all means try the keystroke combination on your system, but don’t be surprised if it doesn’t work. I find the only reliable way to get a non-breaking space character you can use is to explicity choose the item after opening the Symbols dialog.
- Select and copy the non-breaking space in your text caption. (In a moment you will be pasting it into a new user variable.)
Part 2: Create the user variable
- From the Project menu, click the Variables option to open the dialog.
- In the Variables dialog, click the Add New button to create a new variable.
- Give the variable an appropriate name (e.g. var_NonBreakingSpace etc).
- Place your mouse cursor in the Value field and paste the non-breaking space character you copied from the text caption earlier. (You should see the mouse cursor now sitting slightly more to the right in the Value field.)
- Add a Description to explain what this variable is for so anyone maintaining your content at a later date will understand its purpose. Your variable should now look something like that shown below.
- Click the Save button to finish creating your non-breaking space variable.
Where would you use this variable?
You will find this variable very useful (perhaps even essential) anytime you need to do string concatenation to create dynamic feedback messages in Captivate interactions.
- You may want to use variable values to concatenate strings and create dynamic feedback error messages for text entry box validation.
- Use a non-breaking space variable when concatenating text strings to give feedback about the enabled or disabled state of a button, including how many more times you would be allowed to click it.