Dot syntax
Dot syntax is a concise form of Lingo that makes longer scripts easier to read and comprehend for
users who have at least a basic understanding of the language. By understanding and using dot
syntax, you can make your scripts shorter and easier to read and debug. An understanding of
dot syntax makes it easier to learn other programming languages, since many of them use dot
syntax exclusively.
If you are just beginning to learn Lingo, you will probably want to start with verbose syntax and
then begin using dot syntax as your understanding of Lingo improves. You can use verbose
syntax and dot syntax in combination. You may want to do this as you begin the process of
learning dot syntax.
Because most users will want to use dot syntax after they achieve a basic understanding of Lingo,
most of the Lingo examples in this book are written with dot syntax. However, this chapter will
provide extensive examples of both syntaxes.
Almost any Lingo statement can be written with either verbose syntax or dot syntax. The
following example demonstrates how the two types of syntax relate to each other.
This statement sets the forecolor of sprite 12 to 155 using verbose syntax:
set the forecolor of sprite 12 to 155
The following statement does the same thing by using dot syntax. It also omits the
command, which is optional:
sprite(12).forecolor = 155
You can use dot syntax to express the properties or functions related to an object or to specify
a chunk of text within a text object. A dot syntax expression begins with the name of the
object, followed by a period (dot), and then the property, function, or text chunk that you
want to specify.
For example, the
the Stage. The expression
As another example, the
expression
member("Hot Button").number
cast member.
Expressing a function related to an object follows the same pattern. For example, the
pointInHyperLink
text sprite. In addition to the syntax demonstrated in the Lingo Dictionary, you can use the dot
syntax
textSpriteObject .pointInHyperlink()
The following
put
depending on whether the pointer is located over a hyperlink in the text sprite in channel 3:
put sprite(2).pointInHyperlink(mouseLoc)
This is how the same statement is written with verbose syntax:
put pointInHyperlink(sprite 2, the mouseLoc)
To identify chunks of text, include terms after the dot to refer to more specific items within text.
For example, the expression
of the text cast member News Items. The expression
Items").paragraph(1).line(1)
expressions are available only with dot syntax.
property indicates a sprite's horizontal and vertical position on
loc of sprite
sprite(15).loc
cast member property specifies a cast member's number. The
number
text sprite function reports whether a specific point is within a hyperlink in a
statement will evaluate the specified expression and return
member("News Items").paragraph(1)
refers to the first line in the first paragraph. These text chunk
refers to the
loc of sprite
refers to the cast member number of the Hot Button
to express this function.
member("News
set
property of sprite 15.
or
TRUE
FALSE
refers to the first paragraph
Writing Scripts with Lingo 393
Need help?
Do you have a question about the DIRECTOR MX-USING DIRECTOR MX and is the answer not in the manual?