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

Re: content of selection


  • Subject: Re: content of selection
  • From: "email@hidden" <email@hidden>
  • Date: Thu, 15 Oct 2009 07:41:31 -0700

It seems to work if you don't put the selection in a variable first:
tell application "AppleScript Editor"
	tell document 1
		set myText to the contents of the selection
	end tell
end tell

HTH,

ES
On Oct 15, 2009, at 6:38am, Thomas Fischer wrote:

Hello,

I am new to this mailing list, and did not find an answer to my problem searching the archives.
So please excuse me if it is there somewhere and I missed it.


I'm trying to get at selected text in the "AppleScript Editor" and don't see how to get it.
To pinpoint some of the problems I use the following script:


tell application "AppleScript Editor"
	tell document "AdobeTest.scpt"
		set theSelection to the selection
		set myText to characters 289 thru 303
		set myText to the contents of theSelection
	end tell
end tell

This gives the result:

tell application "AppleScript Editor"
get selection of document "AdobeTest.scpt"
--> characters 289 thru 303 of document "AdobeTest.scpt"
get characters 289 thru 303 of document "AdobeTest.scpt"
--> {"\t", "t", "e", "l", "l", " ", "w", "i", "n", "d", "o", "w", " ", "1", "\r"}
get characters 289 thru 303 of document "AdobeTest.scpt"
--> error number -1720 from characters 289 thru 303 of document "AdobeTest.scpt"
Ergebnis:
error "„AppleScript Editor“ hat einen Fehler erhalten: Ungültiger Bereich."
number -1720 from characters 289 thru 303 of document "AdobeTest.scpt"
(„AppleScript Editor“ received an error: Invalid range.", I suppose)


I find it confusing that the call
get characters 289 thru 303 of document "AdobeTest.scpt"
gives the correct result when sent as
"set myText to characters 289 thru 303 as text"
and an error when given as
"set myText to the theSelection as text"

Has anybody any suggestions?

All the best
Thomas _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden


_______________________________________________
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: content of selection
      • From: Thomas Fischer <email@hidden>
References: 
 >content of selection (From: Thomas Fischer <email@hidden>)

  • Prev by Date: content of selection
  • Next by Date: make new as alias
  • Previous by thread: content of selection
  • Next by thread: Re: content of selection
  • Index(es):
    • Date
    • Thread