Re: Filter References and TextEdit
Re: Filter References and TextEdit
- Subject: Re: Filter References and TextEdit
- From: Paul Berkowitz <email@hidden>
- Date: Thu, 01 Aug 2002 00:14:13 -0700
On 7/31/02 4:27 PM, "John Delacour" <email@hidden> wrote:
>
At 2:49 pm -0700 31/7/02, Christopher Nebel wrote:
>
>
> The problem is that you're using a singular class name, not a
>
> plural. Change "document" to "documents" or "every document" and
>
> you'll get a list of documents that match. (This has got to be a
>
> bug, but I'm not sure whether it's a problem with TextEdit or
>
> AppleScript.)
>
>
>
> --Chris Nebel
>
> AppleScript Engineering
>
>
It's always been like that and I would NOT say that it's a bug.
>
'documents' is shorthand for 'every document' and the ae will be
>
compiled accordingly. 'app' is an abbreviation for 'application'
>
_in_certain_contexts_ but you use abbreviations at your peril because
>
'app file' means nothing, as you will see if you try to compile this
>
>
tell app "Finder" to app file id "ToyS'
>
>
The event viewer always logs the standard syntax and it is best for
>
learners to stick to this and use the fancy or abbreviated syntax
>
only when they are familiar with Apple Events.
>
i agree completely with John. However both of you are missing another error
which is going to hit Seth if the document is on his startup disk, plus yet
another OS X AppleScript bug which doesn't error, just gets it wrong:
tell application "TextEdit"
set foo to every document whose path contains "Disk/Folder/File"
end tell
--> {}
if its on the startup disk. Unix paths don't include the name of the startup
disk.
tell application "TextEdit"
set foo to every document whose path contains "/Folder/File"
end tell
--> {document 1}
So why not try to get the FIRST document whose path...etc, to avoid the
list?
tell application "TextEdit"
set foo to first document whose path contains "/Folder/"
end tell
--> {document 1}
In AS 1.8.3, it's still a list, although he correct document. If you try to
compensate for this bug:
tell application "TextEdit"
set foo to item 1 of (first document whose path contains "/Folder/")
end tell
you get an error because the script compiles as:
tell application "TextEdit"
set foo to Abstract object of (first document whose path contains
"/Folder/")
end tell
ERROR: TextEdit got an error: NSReceiverEvaluationScriptError: 3
since 'item' is a keyword of TextEdit.
If you do:
tell application "TextEdit"
get first document whose path contains "/Folder/"
end tell
set foo to item 1 of result
--> document 1
it's OK for now (although why isn't that 'document 1 of application
"TextEdit"?) but you will get an error when the 'first' bug is fixed in a
later release of AppleScript.
Isn't it wonderful?
--
Paul Berkowitz
_______________________________________________
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.