Chapter 7. Strings
In this chapter we explore string manipulation commands and techniques. Chapter 10, Keyboard Events, covers detecting and analyzing keyboard input. See also Chapter 12, Text and Fields, in Director in a Nutshell, which covers the different types of cast members that can display text in Director, fonts and character mapping, scrolling text, and field-related Lingo including hypertext functions.
Strings and Chunk Expressions
A string is a collection of characters that can include non-visible characters such as spaces and carriage returns. A chunk expression is Macromedia’s term for a string or a substring (a portion of a string). To concatenate two strings is to join them together to form a single string. The different chunk types are summarized in Table 7-1, and the Lingo commands that manipulate strings are shown in Table 7-2.
Chunk Expressions
A chunk expression usually takes the form:
chunk firstChunk
{tolastChunk
}
where chunk
is either char
, word
, item
, or line
, and firstChunk
and lastChunk
are integers.
Warning
If firstChunk
is less than 1, the result is the entire string! If lastChunk
is less than firstChunk
, the result is EMPTY (unless lastChunk
is 0, in which case firstChunk
is returned).
The following quirk occurs on both platforms in D6.0.2 and prior versions. Instead of returning an EMPTY
string, if the starting chunk is 0 or negative, the chunk expression returns the entire string:
put char 0 of "Macromedia" -- "Macromedia" put char −1 to 3 of "Macromedia" -- ...
Get Lingo 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.