A reference to
A reference to
- Subject: A reference to
- From: Doug McNutt <email@hidden>
- Date: Fri, 8 Aug 2003 16:07:16 -0600
I want to elicit an erudite discussion of the English-like phrase "a reference to" in AppleScript.
The subject application is Eudora but the defining document is the AppleScript Language Guide.
I hereby declare that the terms "pointer" and "handle" which are well defined in the (classic) Mac OS shall be legitimate words in the ensuing discussion in spite of the fact that they are obviously deprecated in the "user-oriented-objects-required" world of AppleScript.
These are from the dictionary for Eudora 5.1
******
set: Set an object's data
set reference -- the object to change
to anything -- the new value
move: Move object to a new location
move reference -- the object to move
to location reference -- the new location for the object
Result: reference -- to the object after they (sic) have been moved
count: Return the number of elements of a particular class within an object
count reference -- the object whose elements are to be counted
each type class -- the class of the elements to be counted. Keyword 'each' is optional in AppleScript
Result: integer -- the number of elements
******
I have an immediate problem in that the term "reference" as applied to the command "set" seems to be different from the same word used for the "move" command. If I refer to President George III you probably know who I am talking about. I have referred to the current president of the US of A by a reasonable title. King George V would have been the nemesis of President George I. Names ARE references, at least in English grammar as I learned it.
Names, in assemblers are assigned to addresses in "core" memory, if anyone remembers what magnetic cores looked like. It appears that in AppleScript "a reference to" somehow implies an indirect reference in which the contents of a named variable is accessed and then used as an address in core where the value is stored. But perhaps it is really an address of a pointer in a memory manager which is a double indirect pointer. Whonoze? Apple's policy seems to be that we are not supposed to care.
The following are some simple experiments with Eudora 5.1. What I would really like to see is some discussion that makes sense out of the wording. Yes. I want an academic discussion. Examples of scripts that work don't help at all. (JD please take notice.) It's a fundamental understanding of the jargon that needs to be generated. Is there, somewhere, a list of reserved phrases in AppleScript? If so I would really like to search it for definitive definitions.
There is a problem with message length.
<T> means tell application "Eudora"
</T> means end tell
******
<T>
set mynewitem to "something"
</T>
mynewitem
--> "something"
This proves that a "reference" in a set command (to Eudora) expects a simple name in spite of the dictionary entry.
******
<T>
set mynewitem to count items in front window
</T>
mynewitem
--> Can't get every item of window 1
This proves that Eudora simply can't count regardless of what the dictionary says.
******
<T>
set windowref to a reference to front window
set mynewitem to count items in windowref
</T>
mynewitem
--> Can't get every item of window 1
This proves that Eudora's problem isn't just the definition of "reference to".
******
<T>
set mynewitem to name of front window
</T>
mynewitem
--> "In"
As expected. It actually works! I did not need "a reference to".
******
--> After "selecting" the top message in the "In" mailbox:
<T>
set mynewitem to message 0
</T>
mynewitem
--> complete test of selected message.
As expected, I guess. The complete text? Why not a reference? I didn't say "copy"
******
<T>
set mynewitem to subject of message 0
</T>
mynewitem
--> "Would You Like To Save On Your Mortgage? yguhlteqmhwkym"
As expected.
******
<T>
move message 0 to mailbox "Trash"
</T>
--> Eudora got an error. Some parameter is missing for move.
Why not? "message 0" is a reference to the selected message, at least in English-like syntax.
******
<T>
set msgref to a reference to message 0
move msgref to mailbox "Trash"
</T>
--> Eudora got an error. Some parameter is missing for move.
Why not? "mailbox 'Trash'" is a reference to Eudora's trash, at least in English-like syntax.
******
<T>
set msgref to a reference to message 0
set destref to a reference to mailbox "Trash"
move msgref to destref
</T>
--> Eudora got an error. Some parameter is missing for move.
Why not? Dammit. They're both POINTERS in my lexicon.
******
<T>
set msgref to a reference to message 0
set destref to a reference to mailbox "Trash"
-- move msgref to destref
</T>
destref
--> mailbox "Trash" of application "Eudora"
That reference (pointer) seems OK.
******
<T>
set msgref to a reference to message 0
set destref to a reference to mailbox "Trash"
-- move msgref to destref
</T>
msgref
--> message 0 of application "Eudora"
That reference (pointer) seems OK.
******
In case you ask, there still is a message selected (blackened) in the "In" mailbox
******
<T>
set msgref to a reference to message 0
set destref to a reference to mailbox "Trash"
move msgref to destref
</T>
--> Eudora got an error. Some parameter is missing for move.
Still won't play.
******
<T>
set msgref to a reference to message 0
set destref to a reference to end of mailbox "Trash"
move msgref to destref
</T>
--> message id 1.883985223E+9 of mailbox "Trash" of application "Eudora"
This came from an example by Mr. Delacour. I can't claim any understanding. It's magic.
******
This one actually worked! What the HELL is magic about "end of"? I really don't care where it went in the trash. How am I supposed to discover that syntax? Is destref a pointer into the bowels of the mailbox table of contents?
******
With yet another message blackened:
******
<T>
set msgref to a reference to message 0
set destref to a reference to start of mailbox "Trash"
move msgref to destref
</T>
--> Eudora got an error. Some parameter is missing for move.
******
<T>
set msgref to a reference to message 0
set destref to a reference to beginning of mailbox "Trash"
move msgref to destref
</T>
--> Eudora got an error. Some parameter is missing for move.
And . . . the word "beginning" is converted to bold implying that somebody knows about it.
******
Same thing with "start" instead of "beginning" but the word "start" does not get bolded by the Script Editor. JD's "end of" seems to be magic. How can we get anything done without his examples?
******
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
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.