Re: exists ... index 0 returns true
Re: exists ... index 0 returns true
- Subject: Re: exists ... index 0 returns true
- From: kai <email@hidden>
- Date: Wed, 7 Sep 2005 00:45:24 +0100
On 6 Sep 2005, at 03:03, Shane Stanley wrote:
On 6/9/05 11:52 AM, "Matt Neuburg" <email@hidden> wrote:
tell application "TextEdit"
tell document 1
exists word 0 -- true
end tell
end tell
I regard this as a bug.
Interestingly, it returns false if the document contains no words.
Apparently, the issue goes even further.
The document used to get the following results contained a single
paragraph: "Wot, no error number -1728?":
----------------
tell application "TextEdit"
tell document 1
characters 0 thru 27
--> {"W", "o", "t", ",", " ", "n", "o", " ", "e", "r", "r",
"o", "r", " ", "n", "u", "m", "b", "e", "r", " ", "-", "1", "7", "2",
"8", "?"}
characters 0 thru 28 (* or more *)
--> Error number 1: "NSReceiverEvaluationScriptError: 4" (at
least it errors)
words 0 thru 5
--> {"Wot", "no", "error", "number", "1728"}
words 0 thru 7 (* or more *)
--> {"Wot", "no", "error", "number", "1728", missing value,
missing value}
paragraphs 0 thru 1
--> {"Wot, no error number -1728?"}
paragraphs 0 thru 3 (* or more *)
--> {"Wot, no error number -1728?", missing value, missing
value}
end tell
end tell
----------------
Some of this seems symptomatic of general behaviour in Cocoa - at
least in terms of element 0 being considered the same as element 1.
For example:
----------------
tell application "TextEdit"
window 0
--> window id 659 of application "TextEdit"
window 1
--> window id 659 of application "TextEdit"
windows 0 thru 1
--> {window id 659 of application "TextEdit"}
end tell
----------------
tell application "Mail"
window 0
--> window id 554 of application "Mail"
window 1
--> window id 554 of application "Mail"
windows 0 thru 1
--> {window id 554 of application "Mail"}
end tell
----------------
tell application "Safari"
window 0
--> window id 357 of application "Safari"
window 1
--> window id 357 of application "Safari"
windows 0 thru 1
--> {window id 357 of application "Safari"}
end tell
----------------
However, in iTunes (which I believe is a Carbon app), the results are
quite different:
----------------
tell application "iTunes"
window 0
--> error number -1728: "iTunes got an error: Can't get window 0."
window 1
--> browser window id 531 of application "iTunes"
windows 0 thru 1
--> error number -1728: ""iTunes got an error: Can't get windows
0 thru 1."
end tell
----------------
---
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