• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Modifications and Variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifications and Variables


  • Subject: Re: Modifications and Variables
  • From: Paul Berkowitz <email@hidden>
  • Date: Sun, 05 Jan 2003 12:20:39 -0800

On 1/5/03 11:49 AM, "Axel Luttgens" <email@hidden> wrote:

>> The muddy area is the statement that all top-level variables are global. In
>> fact, they're not global unless they're explicitly declared global, either
>> at the top level itself, or in individual handlers as you've been doing.
>
> No, I really believe they are globals, as any other explicitely declared
> global.
> By writing statement 'set x to 3' at the script's top level, without any
> 'property x...' or 'global x' statement, I am really declaring, creating and
> initializing a global variable.
> This would be the "first valid occurence" of identifier 'x', hence the
> declaration.
> And that variable exists, without needing to be referenced in another handler
> through a 'global x' statement.
> But the fact that I may reference it from within a handler through such a
> statement just means it is a global.
> And because it exists and is a global, it will persist.
>
> Now, this is just (what I hope to be) a logical deduction, without any
> technical background, and I could of course be completely wrong.
> Perhaps do you have a reference that establishes a true/technical difference
> between a genuine global and a "semi-global"?
>>


Script A:

---------------------
global x

set x to 3

myHandler()

on myHandler()
display dialog (x as string)
end myHandler

--------------------


Script B:

---------------------

set x to 3

myHandler()

on myHandler()
display dialog (x as string)
end myHandler

--------------------



--ERROR: The variable x is not defined.


If x is a global, then why is it undefined?

--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Modifications and Variables
      • From: Axel Luttgens <email@hidden>
    • Re: Modifications and Variables
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Scripting OS X Address Book
  • Next by Date: Re: AppleScript Wizards
  • Previous by thread: Re: Modifications and Variables
  • Next by thread: Re: Modifications and Variables
  • Index(es):
    • Date
    • Thread