Re: Before I forget
Re: Before I forget
- Subject: Re: Before I forget
- From: deivy petrescu <email@hidden>
- Date: Sat, 22 Mar 2008 11:59:02 -0400
On Mar 19, 2008, at 0:24, Christopher Nebel wrote:
On Mar 16, 2008, at 1:04 PM, deivy petrescu wrote:
The Guide mentions constant, I remember being brought up that
constants are not very constants in AS.
For instance
set pi to 3
makes pi=3!!!
But I was not aware that one could set other constants as well
The new Guide is less unclear on the meaning of "constant" than the
old one, but you have to read rather carefully. I assume you're
referring to the Global Constants in AppleScript section -- if you
look, you'll notice that it says that "AppleScript" is a constant
referring to a script object with a variety of properties, which are
all writable. In other words, "AppleScript" itself is a constant --
you can't set it to something else. That doesn't mean that the
object it refers to is a constant, however. If you're familiar with
modern C, this is similar to the distinction between "const T *" (a
mutable pointer to a constant T) and "T * const" (a constant pointer
to a mutable T).
Chris,
I had to reread your answer many times to try to get it. I think I do
now, however, I am having a hard time to accommodate such
flexibility, though!
Another point, even when using "local" declaration, the variable is
kept on the script. Which is kind of weird considering the example
I posted. The following
set mypasswd to "bomdia"
will show "bomdia" on your script whether it is declared as local
or not.
That is save the script above and open it in TextEdit. "bomdia"
will be clearly readable.
This differs than what I'd expect using "local".
You're assuming that that value is stored in the local variable. It
isn't. You're looking at the value of "result" global, which, as a
global variable, is archived.
--Chris Nebel
AppleScript Engineering
Thanks! It should have been obvious. But it wasn't.
This script does the job showing it.
-------
local x
try
set result to result + 1
log result
-->"" first pass
--> 2 any other run
set x to x + 1
on error
set x to 1
end try
---
_______________________________________________
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