Using Escape Sequences in Cinema Actions

Written by Kevin Cloutier on Nov 14, 2023 2:56 pm

What is an escape sequence?

From Wikipedia, an escape sequence is a combination of characters that has a meaning other than the literal characters contained therein.  Ab Escape Sequence starts with a backslash (\) and is followed by a character.  The most common Escape Sequences would be \r for carriage return and \n for linefeed.  These are usually used to denote a break between commands.  Some Escape Sequences can require additional information to be included in the sequence.

It is important to understand that these escape sequences get converted before sending the bytes.  The escape sequences differ from device to device and the correct sequence is defined by the device you are sending from.  One device might want a carriage return entered as \r, like the JNIOR, and another might want it entered as \0d

What Escape Sequences are available?

\0: NULL
\r: Carriage Return
\n: Linefeed
\b: Backspace
\t: Tab
\\: Backslash
\”: Double Quote
\x##: HEX value

Here we see the example where the \x requires two more digits to be entered following the \x.  These digits are hexadecimal digits (0-9, a-f, A-F).  Capitalization does not matter.  Any value can be entered as a HEX value.  For instance, \r has a decimal value of 13 or a hexadecimal value of 0d and can be entered as \x0d.  The lowercase letter k has a hexadecimal value of 6b and can be entered as \x6b.  It is much easier to use printable characters where you can.  Printable characters and escape sequences can be intermixed.

Sometimes a double quote (“) cannot be entered because it has another meaning.  For example, when declaring a string we start and end that string with a double quote.  Entering a double quote in the middle of that string would confuse the code about where the string should actually end.  In this case, we can escape that interior double quote.

Special Note about Commas

Commas in Cinema Actions are special.  Unfortunately, the macro file is stored in CSV format.  That means all fields are separated by commas.  Entering a comma in the data field for an action will confuse the whole macro file.  The prevent confusion you should escape the comma and use the hexadecimal value \x2c.

Special Note about Double Quotes

Double quotes are also special in Cinema Actions.  At one time they were used as in the above example to define strings.  Double quotes should always be escaped.  There is a special escape sequence for double quotes, \",  where there are not for commas.

On this page
Tags