Re: Code referenced by variable runs but variable undefined
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