O'Reilly logo

Lingo in a Nutshell by Bruce A. Epstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 {to lastChunk}

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" -- ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required