Conditional Execution
You can have Director execute different Lingo code in response to various conditions. Any non-zero expression (including negative numbers) is considered TRUE, and only an expression that evaluates to zero is considered FALSE. Refer to Chapter 5 for details on evaluating comparisons, including compound expressions. (These example multi-line code fragments must be placed in a handler for testing.)
If...Then...Else...End If Decisions
The if statement will execute different Lingo code based on the value of the specified expression. This allows you to, say, use a single Director movie on both Macintosh and Windows but branch to different code depending on the playback platform, as determined by the platform property, such as:
if (the platform starts "Windows") then -- Do Windows-specific stuff here else -- Do Macintosh-specific stuff here end if
The if statement has many possible forms, but I recommend only these. Items shown in curly braces are optional. Note the correct indentation:
Single-Clause If...Then...End If
ifexpressionthenstatement1statement2end if
Multiple-Clause If...Then...Else If...Else...End If
The else if and else clauses are optional:
ifexpressionthenstatement1{else ifexpressionthenstatement2}{elsedefaultAction}end if
For example:
if x = 1 then go frame "Slide1" else if x = 2 then go frame "Slide2" else if x = 3 then go frame "Slide3" else go frame "End" end if
One-Line and Two-Line If Statements
The following forms are theoretically valid, but ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access