Re: Three simple FMP questions
Re: Three simple FMP questions
- Subject: Re: Three simple FMP questions
- From: John W Baxter <email@hidden>
- Date: Mon, 9 Jul 2001 00:31:41 -0700
At 20:34 -0700 7/8/01, Paul Berkowitz wrote:
>
I bet someone thought this was clever too - to default to just a record,
>
rather than a single-item list of records when there's just one. Sure.
At the Apple event level, there is not much difference between a single
thing and a list containing just that one thing. All the application
programmer need do is ask for a list, and if just the one thing was
presented, it will be coerced* by Apple Event Manager to the list of one
thing. It was easy early on (and FileMaker scripting goes back to the days
of "early on") to forget that AppleScript does care about the difference.
(* At the bits and bytes level, that coercion involves changing the type
code in the descriptor, and slapping 14 (I think it is) bytes of fixed
(almost) boiler plate in front of the data handle. The reverse: list of
one item to that item is a matter of throwing away the boiler plate and
changing the type code. AE Manager does that automatically, too.)
Claris did provide a rather nice supplement to the dictionary, in the form
of the database which describes the scripting model much better than the
dictionary can (not does: can...there are limits to what can be
accomplished within the confines of the 'aete' which the visible dictionary
merely displays). The limits are built into the data structure.
Suppose my application accepts, in some event parameter, either of two
classes representing the same data, or lists of either of those classes, or
a list containing a mixture of the two classes. I cannot describe that in
other than a huge multi-line comment in the 'aete'. I have a choice: I
can pick one of the classes and name it, or I can say "anything". The
latter is a bigger lie than the former.
I've just described a simplification the situation for the scriptable
(current) Finder: which in many places accepts
references of the 'file "spam" of folder "ham" of disk "eggs"' form
file specifications of the form 'file "spam" as file specification'
(which lives as file "diskname:Desktop Folder:spam"...
you can use a full path to anywhere)
file things of the form 'file "diskname:Desktop Folder:spam"
aliases
(Can Finder be given the file system "id" number of a file?...I'm not sure,
but a quick--late night--experiment suggests not...
Finder will happily give you that number)
lists of any of those
lists of a mixture of some or all of the the forms
The Finder team settled for mentioning only the first form, as "reference"
(now...I'm not sure that's what it was called when Scriptable Finder first
appeared, but I *think* it was more obvious then that reference meant the
first form...it's been a while). One could also consider that "reference"
covers the first three forms.
[A Jon's Commands coercion makes it appear that a string like
"diskname:Desktop Folder:spam" is also accepted, but that gets coerced to
one of the other forms (the second, I think) before Finder sees it.]
To convince yourself that
file "file path string here" as file specification
differs from
file "file path string here"
run a script like this, substituting your disk name and a suitable file on
its desktop
tell application "Finder"
activate
local x
set x to file "Vashon:Desktop Folder:bbedit" as file specification
display dialog (class of x) as string
set y to file "Vashon:Desktop Folder:bbedit"
display dialog (class of y) as string
select x
end tell
I think FileMaker's dictionary could be improved from what it is...I don't
think it can contain the whole truth, just as Finder's can't.
--John
--
John Baxter email@hidden Port Ludlow, WA, USA