• 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: path to selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: path to selection


  • Subject: Re: path to selection
  • From: Philippe GRUCHET <email@hidden>
  • Date: Fri, 7 Mar 2003 20:25:16 +0100

Simon,

Please, let me know if it works under 9.1.

Almost...
=================
tell application "Finder"
if selection = {} then return

set {theList, AppleScript's text item delimiters, textHolder} to {selection as list, ",", ""}

repeat with i from 1 to items's number in theList
copy ((theList's item i as alias) & return & textHolder) to textHolder
end repeat
activate -- I added this - see next line
set the clipboard to textHolder -- OS9 - error: Must activate Finder

set AppleScript's text item delimiters to ""
display dialog (textHolder as string) buttons {"OK"} default button "OK"
end tell
=================
Worked except that the _set clipboard_ doesn't work in the background. Had to activate Finder first.

Hmm... 'set the clipboard to' is not a Finder command but a StandardAdditions's.
It's probably better to put it outside the tell block:

=================
tell application "Finder"
if selection = {} then return
set {theList, AppleScript's text item delimiters, textHolder} to {selection as list, ",", ""}
repeat with i from 1 to items's number in theList
copy "alias " & ("\"" & (theList's item i as alias) & "\"" & return & return & textHolder) to textHolder
end repeat
set AppleScript's text item delimiters to ""
end tell

set the clipboard to textHolder
display dialog (textHolder as string) buttons {"OK"} default button "OK"
=================

But you've found the trick. Great!


Thanks for clarifying that you're using OSX. I don't have the hardware to run it yet but am trying to stay in touch for the day I do.

My fault Simon! I didn't remember the configuration you put at the end of your messages.


Interesting that _if selection =1_ worked on your machine. I guessed it implied that the default property of (Finder) selection was count rather than value. Is that the case?

Yes, I begun this script with numbers, not with Finder items (file, folder, etc.):
(Reason why I let these lines.)

=================
tell application "Finder" to if (count of (get selection)) = 1 then selection as alias
=================


Or am I just trying to (inappropriately) apply VB concepts to Applescript?

Not at all. Your comment about this statement was very appropriate!


Kind regards,
Philippe Gruchet/SVM Mac
VNU Publications France
http://svmmac.vnunet.fr
_______________________________________________
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.

References: 
 >Re: path to selection (From: Simon Brown <email@hidden>)

  • Prev by Date: Re: Big numbers (again) and complex routine
  • Next by Date: Re: Searching for the equivalent of coercing to type "record"
  • Previous by thread: Re: path to selection
  • Next by thread: Re: path to selection
  • Index(es):
    • Date
    • Thread