At 06:02 PM -0500 11/13/01, "Genevieve Young" <[EMAIL PROTECTED]> wrote: >In Lingo in a Nutshell, Pg 331, Bruce Epstein has thoroughly confused me: > >�Property variables ( beginning with the letter �p� for clarity ) are used >instead >of global variables. Properties are declared with the keyword property, >and can contain a different value for each instance of the object (that is, >each timer). If we used global, multiple timers would trample the values >held in the globals.�
Note: I don't usually have time to monitor all posts on Lingo-L, so write to me privately at [EMAIL PROTECTED] if you have a question about something in one of my books. The above quote is taken a bit out of context. In the book, I first explain how to make a "timer." Then, to explain objects and property variables, I explain how to make a *re-usable* timer. The above sentence is a little harder to understand out of context and without the formatting. There is an extensive discussion of global and property variables throughout the book. There is also a slight misquote. The book explains: "Note these differences [in example 12-8] from the procedural version [of the timer shown earlier] in Example 12-5: <i>Property</i> variables (beginning with the letter "p" for clarity) are used instead of <i>global</i> variables. Properties are declared with the keyword <i>property</i>, and can contain a different value for each instance of the object (that is, each timer). If we used globals, multiple timers would trample the values held in the globals. Here's what I mean: By definition, globals (i.e. global variables) are shared among every piece of Lingo that uses them. Therefore, if I change a global variable called "gCurrentTime", it affects every place that it is used. Thus, you couldn't create multiple independent timers that used a single global variable (all timers would always "share" the same time). If you wanted to implement 3 independent timers using global variables, you'd need a separate global variable for each one (such as "gCurrentTime1", "gCurrentTime2" and "gCurrentTime3"), which is very annoying and inefficient. When you want to create multiple similar things that are independent, it is usually a good idea to use property variables. In the example, to create a "reusable timer" we can declare "pCurrentTime" as a property variable. When we create separate timers from a timer object (as explained in the book), each timer gets its own *copy* of pCurrentTime. Lingo handles the book-keeping for you automatically so that each "instance" of the timer can easily access its own pCurrentTime. Does that clarify things? Regards, Bruce ----- "Dreamweaver in a Nutshell" published by O'Reilly & Associates. Co-authored by Bruce Epstein and Heather Williamson http://www.amazon.com/exec/obidos/ASIN/0596002394/ref%3Dnosim/zeusproductions Sample chapter: http://www.oreilly.com/catalog/dreamweavernut/chapter/ch06.html ----- [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
