Name

Styled Text

Allowed coercions

list with one item; numbers as long as the string is a valid integer or real

Syntax

set myString to "Styled string" as Styled Text

Description

Styled Text is a string that can but does not have to contain font and style information. Styled Text has all of the elements and properties of a string. In fact, the class of styled Text is string. This data type also has a length property, which returns the number of characters in the string. Styled Text strings have character, paragraph, text, and word properties. Some word-processing applications, such as AppleWorks, return the styled-text value when you get the text from a document.

The various font and style characteristics of Styled Text are incorporated into the string, but you cannot change them with built-in AppleScript code (as in set font of styledTextVar...). In addition, you can coerce strings back and forth between Styled Text and string. But a literal string (“I am a string”) that is coerced to Styled Text does not actually have any style or font information; it is just plain text.

Get AppleScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.