Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scope for Beginners



I've just (I think) had my first example as a self-taught scripter of why global variables are Bad & Wrong.

Because all my scripts are so far fairly small, I was using global variables/properties at the top of them on the principle that, set it and forget it, the entire script needs to know what this says. Today I've spent about half an hour struggling with a very simple script where I've changed the number 'max' at the top of it from 8 to 16. The value 8 kept coming back from the dead no matter how often I recompiled with 'max=16'. I'd assumed that if it's not a stay-open script it doesn't have a persistent context.

After spending half an hour trying to see where it said, 8, I finally took 'max' out from being a property and it started to work the way I wanted it to.

Is this an example of the stuff Matt N says in his Applescript book about scope and why not to use global variables, or is there something else happening I haven't understood yet?

Confused beginner, R
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-users/email@hidden
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.