Using Director > Writing Scripts with Lingo > About variables > Using local variables

 

Using local variables

A local variable exists only as long as the handler in which it is defined is running. However, after a local variable is created, you can use the variable in other expressions or change its value while Lingo is still within the handler that defined the variable.

Treating variables as local is a good idea when you want to use a variable only temporarily in one handler. This helps you avoid unintentionally changing the value in another handler that uses the same variable name.

To create a local variable:

Assign the variable a value using the equals (=) operator or the set...= command.

Unless the handler uses the term global to declare that a variable is global, the variable is automatically a local variable.

To display all current local variables in the handler:

Use the showLocals command.

You can use this command in the Message window or in handlers to help with debugging. The result appears in the Message window. The Director debugger can also track the value of local variables. For more information about using the debugger, see Troubleshooting Lingoin the Director Support Center.