• 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: Code referenced by variable runs but variable undefined
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code referenced by variable runs but variable undefined


  • Subject: Re: Code referenced by variable runs but variable undefined
  • From: kai <email@hidden>
  • Date: Sun, 9 Jul 2006 10:22:44 +0100


On 9 Jul 2006, at 00:39, polibek wrote:

The dictionary doesn't explicitly mention "result" under "resize image" so I guess it doesn't. However the lines "return {imgHalfSize, imgGT1000}" and "return {imgHalfSize, imgGT1000}" don't alter the behavior of the script and I have them commented now. I think the problem is related to variable scope but I can't seem to get it right. It stills seems weird to me that the code to resize the image actually runs and then the script decides the variable is undefined.

Let's take a closer look at what happens when we try to set a variable to the result of a command that doesn't return a result, polibek.


A statement like this:
--------------
set today to current date
--------------

Is equivalent to:
--------------
current date
set today to the result
--------------

In other words, the command is first executed - and the result is then assigned to the variable.

Where a command returns no result, the variable is undefined. This becomes evident only when you try to subsequently use the variable - since that's the point at which an attempt is made to get its value:

--------------
set some_variable to beep
some_variable
--> error number -2753 [OSAUndefinedVariable]: "The variable some_variable is not defined."
--------------


Even when it has previously been assigned some other value, a variable will still be rendered undefined in such conditions:

--------------
set some_variable to "Some string."
display dialog some_variable
--> [dialog] "Some string."

set some_variable to beep
display dialog some_variable
--> [error] "The variable some_variable is not defined."
--------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Code referenced by variable runs but variable undefined
      • From: polibek <email@hidden>
References: 
 >Code referenced by variable runs but variable undefined (From: polibek <email@hidden>)
 >Re: Code referenced by variable runs but variable undefined (From: Emmanuel <email@hidden>)
 >Re: Code referenced by variable runs but variable undefined (From: polibek <email@hidden>)

  • Prev by Date: Re: UI scripting "Show Infos"
  • Next by Date: Re: UI scripting "Show Infos"
  • Previous by thread: Re: Code referenced by variable runs but variable undefined
  • Next by thread: Re: Code referenced by variable runs but variable undefined
  • Index(es):
    • Date
    • Thread