Lingo in a Nutshell and Director in a Nutshell banner

Lingo in a Nutshell

List of Examples

 

Example Description Page
1-1 Hello World 6
1-2 Nested Handler Calls 8
1-3 A Recursive Function 9
1-4 Calling a Function Non-recursively 10
1-5 Handler Scope 13
1-6 Returning a Value from a Function 16
1-7 Returning Prematurely from a Function 17
1-8 Creating Scripts at Runtime 21
1-9 Using Local Variables 26
1-10 Using Parameters 27
1-11 Using Global Variables 28
1-12 Using Property Variables 30
1-13 Common Errors with Global Variables 33
1-14 Passing Globals Variables as Parameters 34
1-15 Persistent Variables 35
1-16 One-Time Initialization 36
1-17 Comments 39
1-18 Handler Declarations 42
1-19 Nested Multi-Line Structure Errors 43
1-20 Nested If Statements 45
1-21 Common If Statement Errors 46
1-22 Nesting If Statements Properly 47
1-23 Using End If Improperly 48
1-24 Case Statements 50
1-25 Repeat Loops 51
1-26 Nested Repeat Loops 53
1-27 Customized Repeat Loops 53
1-28 Infinite Loops 54
1-29 A Handler That Accepts Parameters 56
1-30 A Simple Generalized Behavior 58
1-31 A HardCoded Function 58
1-32 A Generalized FileExists Function 59
1-33 Using Generalized Functions 60
1-34 Special Treatment of First Argument to a Function Call 61
1-35 Passing a Script Instance as an Argument 62
1-36 Function Accepting Varying Arguments 63
1-37 Placeholder Arguments 64
1-38 Variable Number of Parameters 65
1-39 Verifying Parameters 66
2-1 Basic Frame and Sprite Scripts 71
2-2 The Phantom Script Bug 75
2-3 Locating Individual Script Types 85
2-4 Primary Event Handlers 88
2-5 Intercepting Built-In Lingo Commands 89
2-6 Using the Me Script Instance Variable 92
2-7 Determining the Stacking Order of a Behavior 93
2-8 Determining a Sprite's Number from Within an Attached Behavior 93
2-9 The SpriteNum of me Property 94
2-10 Sequence of Movie-Related Events 98
2-11 Message Processing Order 104
3-1 Wrapper Scripts 116
3-2 Convenience Functions 117
3-3 Ultra-Convenience Functions 117
3-4 Overriding Built-in Lingo Functions 118
3-5 Centralized Code 119
3-6 Optional Debugging Code 119
3-7 Testing Shortcuts 119
3-8 Debugging Shortcuts 120
3-9 Easter Eggs 120
3-10 Checking the Return Value 121
3-11 Checking for a List Parameter 121
3-12 Assuming Default Values 122
3-13 Tracking the User's Score 124
3-14 Fixing a "Variable Used Before Assigned a Value" Error 131
3-15 A Conditional Breakpoint 134
3-16 Using Put From the Message Window and Scripts 138
3-17 Using Trace, TraceLoad, and TraceLogFile 138
3-18 Simple Override of Default Alert Dialog 139
3-19 The AlertHook 139
3-20 Using On AlertHook 141
3-21 A Simple Sample Debugging Session 143
3-21a Initial attempt to create a handler 143
3-21b Improved repeat loop including "with" 143
3-21c Improved repeat loop including "end repeat" 144
3-21d Attempt to initialize myList 145
3-21e Corrected initialization of myList 145
3-21f A completed handler 146
5-1 Simulating Constants Using Globals 171
5-2 Replacing Integer Codes with Symbols 173
5-3 Avoiding Evaluation of the Second Clause in a Compound Expression 175
5-4 XOR Logical Function 175
5-5 Implicit and Explicit Comparisons 176
5-6 Subtle Errors in Compound Comparisons 177
6-1 Creating Property Lists on Keyboards Without Square Brackets 182
6-2 Two Variables Pointing to a Single List 184
6-3 Dissociating Two Lists 185
6-4 Modifying Lists Passed to a Handler 185
6-5 Using a List in a Handler Without Modifying the Original List 185
6-6 Using Lists to Return Multiple Values from a Handler 186
6-7 Creating and Reading Multidimensional Lists 187
6-8 Sort Order of Linear and Property Lists 190
6-9 Recursively Sorting Sublists 191
6-10 Reverse Sort 191
6-11 Reversing Unsorted Lists 192
6-12 Populating a List with Zeroes 193
6-13 Case-Sensitive Deletion of String Values 195
6-14 Case-Insensitive Deletion of Symbolic Values 195
6-15 Deleting a Range of Elements 197
6-16 Case-Sensitive Searching of String Values 197
6-17 Math Operations Performed on Entire Lists 200
6-18 Math Operations Performed with Two Lists 200
6-19 Preventing Non-list Arguments from Being Passed to List Commands 202
6-20 Extracting Unknown Properties from a List 206
6-21 Printing Each Element's Position in a List 208
6-22 Printing Each Element's Value Only 208
6-23 Creating a List of Random Numbers 208
6-24 Incorrect (Nonrandom) List Creation 209
6-25 Randomizing an Existing List 209
6-26 A Nonrepeating Random Number Generator 210
6-27 Converting a Property List to a Linear List 211
6-28 Creating a Property List from Two Linear Lists 211
6-29 Converting a Text String to a Lingo List 214
7-1 Chunk Expressions 216
7-2 Assigning Text to a Field Cast Member 217
7-3 String Function Practice 222
7-4 String Concatenation Practice 222
7-5 ItemDelimiter Practice 224
7-6 Determining the Drive ID using the ItemDelimiter 225
7-7 Evaluating User Input 225
7-8 Corrected Search-and-Replace Routine 226
8-1 Integer Versus Floating-Point Division 229
8-2 Modulo Division Practice 230
8-3 Converting Time Units Using Integer, Modulo, and Floating-Point Division 230
8-4 Clipping a Value to a Valid Range 233
8-5 Checking If Values Are Within Range 233
8-6 Summing a List of Values 233
8-7 Averaging a List of Values 234
8-8 Recursively Counting Elements in a List 235
8-9 Calculating the Log Base 10 236
8-10 Calculating Powers 236
8-11 Exponential Notation 237
8-12 Converting Between Radians and Degrees 237
8-13 Calculating the Area of a Circle 238
8-14 Elliptical Motion Behavior 238
8-15 Preventing Overflow Conditions While Calculating Factorials 240
8-16 Recursive Factorial Function 241
8-17 Integer Rounding 241
8-18 Integer Truncation 242
8-19 Float Rounding 242
8-20 Float Truncation 242
8-21 Temperature Conversion 243
8-22 Generating Random Numbers in Various Ranges 244
8-23 Simulating a Pair of Dice 245
8-24 Simulating a Coin Flip 245
8-25 One-Eyed Jacks Are Wild 246
8-26 Randomizing an Existing List 247
9-1 Basic Mouse Events 252
9-2 What's My Sprite Number? 256
9-3 Responding to Both Single- and Double-Clicks 262
9-4 Preventing a Double-Click from Executing the Single-Click Action 262
9-5 Preventing Rapid-Fire Clicks 262
9-6 Dragging a Sprite 270
9-7 Build a Better Mouse Trap 270
10-1 Accumulating and Counting Keystrokes 278
10-2 toring the State of Modifier Keys 282
10-3 Preventing the User from Aborting 285
10-4 Trapping the Quit Keys 285
10-5 Setting the Insertion Point 287
10-6 Setting the Highlight in a Field 288
10-7 Disallowing Characters 289
10-8 Allowing Only Specific Characters 289
10-9 Password Entry Field 290
10-10 Special Handling of Editing Keys 292
10-11 Trapping the Numeric Keypad Keys 293
10-12 Key Trap 296
10-13 Passing Key Events from MIAWs 298
10-14 Your Own KeyCode Tester 299
11-1 A Custom Timer 302
11-2 Delay Command versus Custom Wait Function 303
11-3 Waiting for Media 303
11-4 Time Unit Conversion Utilities 310
11-5 Converting Between Frames to HH:MM:SS 311
11-6 Score Duration and Arbitrary Conversion 312
11-7 Projector Expiration and Y2K 314
11-8 Timing Performance 315
11-9 Stop Watch Timer 317
11-10 Symbolic Version of Conversion Utility 317
12-1 A Ludicrously Simple Behavior 322
12-2 Writing Simple Scripts Via the Behavior Inspector 322
12-3 A simplified beeping Behavior 324
12-4 A Trivial Procedural Example 326
12-5 A Procedural Stopwatch 327
12-6 Creating a Child Object from a Parent Script 329
12-7 Instantiating and Using a Child Object 330
12-8 An Object-Oriented Stopwatch 330
12-9 Testing a Timer Object 331
12-10 Paradise Lost? Not as Lost as the Reader! 332
12-11 Child Object References 336
12-12 Reading Properties of Child Objects 337
12-13 The GetBehaviorDescription Method 340
12-14 The GetPropertyDescriptionList Method 341
12-15 Behaving Yourself in Paradise 344
12-16 The RunPropertyDialog Method 344
12-17 The ActorList 347
12-18 Getting Attached Behaviors 348
12-19 Adding Behaviors At Runtime 349
13-1 ShowXlib Output for Director for Macintosh 351
13-2 The Output from NetLingo's mMessageList() 352
13-3 Relief from mMessageList() 352
13-4 Deciphering FileIO mMessageList() 353
13-5 Using Instance-Level Methods 355
13-6 Listing Installed Lingo Scripting Xtras from Lingo 356
13-7 Checking Whether a Specific Lingo Scripting Xtra is Installed 357
13-8 Deciphering mDescribe 360
13-9 Using an XObject 361
13-10 Using an XFCN or XCMD 362
14-1 Viewing File Type and Creator Codes 370
14-2 Moving Down or Up One Folder 373
14-3 Ensuring a file path separator 373
14-4 Extracting the FileName from a Path 374
14-5 Extracting Files in Subfolders 375
14-6 MUI File Save Dialog 375
14-7 Writing to a File 381
14-8 Reading from a File 383
14-9 SetFilterMask 384
14-10 SetFinderInfo and GetFinderInfo 384
14-11 Printing an External Text File 390
15-1 Standard Multibutton MUI Alert Dialog 391
19-1 The Fixed Case of Symbols 522
19-2 Checking If a Symbol Exists 523
19-3 Checking If an Asset Xtra is Installed 524
A-1 ASCII Table Printout 530
A-2 Test for Alpha Character 530
A-3 Test for Alpha Digit 530
C-1 Character Sort Order Ranking 555
C-2 Character Sort Order Ranking Showing ASCII Values 556
C-3 Convert to Uppercase 556
C-4 Distinguishing Between Cases 557
C-5 Intercepting Spaces 560
C-6 Trimming and Deleting Spaces 560
D-1 Using LINGO.INI to Configure a Projector 566
E-1 Error Handling 584



Zeus Home Page | LIAN TOC | DIAN TOC | Links | E-Mail

Place an Order | Downloads | FAQ | GuestBook | Glossary

[End of Page]

Copyright © 1996-1999 Bruce A. Epstein. All Rights Reserved.

(The page last revised July 2, 1999)