Scope for Beginners
Scope for Beginners
- Subject: Scope for Beginners
- From: Ruth Bygrave <email@hidden>
- Date: Sat, 16 Jun 2007 14:45:34 +0100
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:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden