@syntax

This page explains the concept of @syntax which is a feature that can be used in many situations when working with the CpExtra HTML5 widget, but is especially useful when working with xcmnd command variables.

For CpExtra to perform an action on any Captivate slide object, it first needs to identify on which specific slide object the action should be performed.

The simplest way to identify a certain slide object in Captivate is to use its unique object name, which is clearly specified in the field provided at the very top of the Properties tab (as shown highlighted in orange in the screenshot below).

However, sometimes you may want an action to be performed not just on a single slide object, but on a group of slide objects. For example, imagine you have a slide with three objects on it, their object names being:

  • SmartShape_1
  • SmartShape_2
  • SmartShape_3

Now let's say you want to HIDE all three of these objects at once so that they are not visible at run-time.

The most obvious way to do this is to use Captivate Actions or Advanced Actions to hide each object individually. However, this can be time-consuming, and if you ever later decide to add another object to that slide which also needs to be hidden, you would need to find the action responsible for hiding the other objects and modify it by adding another line to hide the extra object.  This is not too difficult, but would still take valuable development time.

Using @syntax can help speed up your e-learning development. The @ symbol is used as a 'wild card' character that can be used to represent any single character or group of characters in an object name.

For example, if you look at the list of objects mentioned above, you'll notice their names all start with: SmartShape_

@syntax can be used to tell CpExtra to hide every object on slide whose name starts with SmartShape_ regardless of what characters come after that prefix.  To do this you would use: SmartShape_@ to instruct CpExtra to select SmartShape_1, SmartShape_2, and SmartShape_3 as the objects on which to perform a given action.

If later you then added additional objects called SmartShape_4 or SmartShape_5, you would not have to change your existing CpExtra code in any way, because all objects still fit the SmartShape_@ rule. Even if you added a shape called SmartShape_ReallyLongAndAmbiguousName, the SmartShape_@ definition would still allow it to be automatically selected and used by CpExtra.

However, @syntax queries are case-sensitive. So an object with the name smartshape_1 or Smartshape_1 would not be affected because they do not exactly match the query definition. 

The @ wild card character does not have to appear at the end of an @syntax query. It can appear anywhere within it.

For example, let's say you have a slide with the following objects.

  • prefix_blah_suffix
  • blah_suffix
  • prefix_blah

The query prefix_@ will select prefix_blah_suffix and prefix_blah. The query @_suffix will select prefix_blah_suffix and blah_suffix. The query prefix_@_suffix will select only prefix_blah_suffix.

In most command variables, where you could input an object name, it will likely also accept an @syntax query. Additionally, in certain xcmnd command variables, @syntax can also be used to select a range of user variables. 

@syntax vs. #syntax

CpExtra allows you to use a @ symbol OR a # symbol to be used as a wildcard. However, queries using @ do not act the same way as queries using #.

Simply put, @syntax selects objects on the current slide (where you're at), whereas #sytnax selects objects across the entire project.

Say you had two slides.

On slide 1 you have these objects:

  • SmartShape_1
  • SmartShape_2

On slide 2 you have this object:

  • SmartShape_3

If when the movie was viewing slide 1 you executed an action on the query SmartShape_@ it would affect SmartShape_1 and SmartShape_2. However, SmartShape_3 would not be influenced.

On the other hand, if on slide 1 you executed an action on the query SmartShape_#, then SmartShape_1, SmartShape_2 and SmartShape_3 would ALL be selected, including any other matching slide objects across the entire project.

IF YOU LIKE WHAT YOU'VE READ ABOVE, THERE'S PLENTY MORE!

Join more than 2500 other Adobe Captivate users just like yourself and receive regular troubleshooting tips, illustrated tutorials, technical information, and creative solutions to real-world e-learning development issues. (See an example here.) Click the button below to join our community.  It's completely FREE!