IMPORTANT: Both Action Code and Export Code do not treat straight and typographic quote characters as equivalents.
The issue of unseen character auto-substitution for OS or app
Only straight single/double quotes have keys on the Mac keyword, whilst the typographic or 'curly' style of quote—more conventionally using in printed text—require use of keyboard shortcuts unfamiliar to many users (see table below). As a result, the macOS frameworks used by Tinderbox often default to auto-substitution of straight quotes into their typographic equivalents. this is true for the $Text area of the Tinderbox text pane.
This auto-substitution of straight quotes with typographic ones can be controlled via the $SmartQuotes boolean system attribute. See more on Smart Quotes, and further below in the section on use of built-in prototypes.
Quotes and Tinderbox Code
In both Action Code and Export Code, only straight quotes, single or double, are treated as valid string delimiters in code. Thus:
WRONG $Color = “red”;
WRONG $Color = ‘red’;
CORRECT $Color = "red";
CORRECT $Color = 'red';
Either form can be used inside a correctly quoted-enclosed string:
CORRECT $MyString = "He said “It’s ‘just’ an example”, then left";
But, take care if using straight quotes inside a string. The next example will not work as expected:
WRONG $MyString = 'He said "It's 'just' an example", then left';
The outer single straight quotes happily enclose the double straight quotes in the string. But, the string also contains straight single quotes, the first of which closes the string, i.e. 'He said "It'. If using typographic quotes in the string is not possible, defining a string that contains both types of straight quotes requires defining the whole text as several discrete stings such that no single string contains a quote of the type used to define the string. For instance:
CORRECT $MyString = 'He said "'+"It's 'just' an "+'example", then left';
Notice how the second string switches to double quotes around the string which contains straight single quotes.
Setting up a TBX file for code work
Because coding in Tinderbox uses the $Text area, auto-substitution of quotes can be problematic. Reflecting this, a number of Tinderbox's built-in prototypes are pre-configured with their $SmartQuotes set to false
thus suppressing quote substitution. These prototypes include:
The different quote types defined
Character | Description | Unicode | macOS | HTML |
---|---|---|---|---|
' | straight single quote | U+0027 (APOSTROPHE) | ' | ' (or ' ) |
" | straight double quote | U+0022 (QUOTATION MARK) | " | " (or " ) |
‘ | opening single quote | U+2018 (LEFT SINGLE QUOTATION MARK) | option + ] | ‘ |
’ | closing single quote | U+2019 (RIGHT SINGLE QUOTATION MARK) | option + shift + ] | ’ |
“ | opening double quote | U+201C (LEFT DOUBLE QUOTATION MARK) | option + [ | “ |
” | closing double quote | U+201D (RIGHT DOUBLE QUOTATION MARK) | option + shift + [ | ” |