• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can not get "item" from "position"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can not get "item" from "position"


  • Subject: Re: Can not get "item" from "position"
  • From: has <email@hidden>
  • Date: Wed, 4 Apr 2007 17:00:12 +0100

Andrei Tchijov wrote:

Now, I want to get to separate items of "position". I though that the way to do it is

tell application "Finder"
	set targetWindow to the front window
	item 1 of position of targetWindow
end tell

But it does not work. I am getting error message :

Can't get item 1 of position of Finder window ...

Don't worry, this catches everyone out the first time.

Finder only understands references that identify objects in its object model, e.g. 'position of front window'. The error occurs because you ask it to 'get item 1 of position of front window', but 'position of front window' identifies a list value, not an application object. Finder doesn't know how to manipulate the contents of values such as strings, lists and records - only AppleScript knows how to do that - so it raises an error when it tries to resolve the 'item 1 of' part of the reference.

What you have to do is to get the list from Finder, then use AppleScript to do the rest. You can do that by inserting your own 'get' command at the appropriate point in the line:

	item 1 of (get position of targetWindow)

HTH

has

p.s. If you want to the position list's items to separate 'x' and 'y' variables, the simplest thing is just to write:

	set {x, y} to position of targetWindow

--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html

_______________________________________________
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
  • Follow-Ups:
    • Re: Can not get "item" from "position"
      • From: Andrei Tchijov <email@hidden>
  • Prev by Date: Re: Can not get "item" from "position"
  • Next by Date: Re: Can not get "item" from "position"
  • Previous by thread: Re: Can not get "item" from "position"
  • Next by thread: Re: Can not get "item" from "position"
  • Index(es):
    • Date
    • Thread