• 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't get it to work
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can't get it to work


  • Subject: Re: can't get it to work
  • From: John Delacour <email@hidden>
  • Date: Wed, 9 Apr 2003 21:02:55 +0100
  • Mac-eudora-version: 6.0a14

At 1:48 pm +0200 8/4/03, Robert Cerny wrote:

tell application "Finder"
set theResult to POSIX path of "/Users/rcerny/Desktop/In"
activate
move selection to theResult
end tell


You're doing things back to front, as you will see if you watch the event viewer -- so many questions could be avoided if people would step though their scripts. And while I'm on a <rant>, theResult is a very bad label for a variable. No variable should begin with "the" and and the name of the variable should bear some close semantic relationship to its contents. (the result) has a special meaning.

It is also unnecessary to bring the Finder to the front.

'POSIX path of' converts a Mac pathname or file reference to a UNIX pathname:

set mac_desktop to path to desktop
-- alias "dx:Users:jd:Desktop:"
set unix_desktop to POSIX path of mac_desktop
-- "/Users/jd/Desktop/"
set mac_desktop to POSIX file unix_desktop
-- file "dx:Users:jd:Desktop:"

If you want to refer to any file in your user folder, not just special folders such as desktop, use 'path to "cusr"' (path to current user folder)

Here are some useful examples. Note the ever perfidious nature of the term 'file':


set mac_april_downloads to "" & (path to "cusr") & "Downloads_Apr_2003"
-- "dx:Users:jd:Downloads_Apr_2003"


set unix_april_downloads to POSIX path of mac_april_downloads
-- "/Users/jd/Downloads_Apr_2003"


set fileref_april_downloads to POSIX file unix_april_downloads
-- file "dx:Users:jd:Downloads_Apr_2003"


try
tell application "Finder" to reveal fileref_april_downloads
on error e
e
end try
-- "Finder got an error: Handler can't handle objects of this class."


tell application "Finder" to reveal fileref_april_downloads as file specification
-- folder "Downloads_Apr_2003" of folder "jd" of folder "Users" of startup disk of application "Finder"


tell application "Finder" to reveal fileref_april_downloads as alias
-- folder "Downloads_Apr_2003" of folder "jd" of folder "Users" of startup disk of application "Finder"
_______________________________________________
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.
  • Follow-Ups:
    • Re: can't get it to work
      • From: Andrew Oliver <email@hidden>
    • Re: can't get it to work
      • From: Paul Berkowitz <email@hidden>
    • Re: can't get it to work
      • From: Reinhold Penner <email@hidden>
References: 
 >can't get it to work (From: Robert Cerny <email@hidden>)

  • Prev by Date: Re: Unicode characters
  • Next by Date: Re: Keyboard Input Menu position differs, has no name.
  • Previous by thread: Re: can't get it to work
  • Next by thread: Re: can't get it to work
  • Index(es):
    • Date
    • Thread