Lingo Dictionary > A-C > chars()

 

chars()

Syntax

chars(stringExpression, firstCharacter, lastCharacter)

Description

Function; identifies a substring of characters in stringExpression. The substring starts at firstCharacter and ends at lastCharacter. The expressions firstCharacter and lastCharacter must specify a position in the string.

If firstCharacter and lastCharacter are equal, then a single character is returned from the string. If lastCharacter is greater than the string length, only a substring up to the length of the string is identified. If lastCharacter is before firstCharacter, the function returns the value EMPTY.

To see an example of chars() used in a completed movie, see the Text movie in the Learning\Lingo Examples folder inside the Director application folder.

Example

This statement identifies the sixth character in the word Macromedia:

put chars("Macromedia", 6, 6)
-- "m"

Example

This statement identifies the sixth through tenth characters of the word Macromedia:

put chars("Macromedia", 6, 10)
-- "media"

Example

This statement tries to identify the sixth through twentieth characters of the word Macromedia. Because the word has only 10 characters, the result includes only the sixth through tenth characters.

put chars ("Macromedia", 6, 20)
-- "media"

See also

char...of, length(), offset() (string function), number (characters)