• 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: Thomas Fischer <email@hidden>
  • Date: Thu, 15 Oct 2009 18:03:50 +0200

Yes, that works!
For now this might suffice, but I can't modify the selection that way (e.g. extend it by a letter before and after or shift it).
And the differences between the two "get characters …" versions remains mysterious, the result windows doesn't seem to tell the whole story there.


Thanks
Thomas


Am 15.10.2009 um 16:41 schrieb email@hidden:

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 (email@hidden )
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

References: 
 >content of selection (From: Thomas Fischer <email@hidden>)
 >Re: content of selection (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: AS apps in sidebar don't accept drag and drop input in SL
  • Next by Date: Re: make new as alias
  • Previous by thread: Re: content of selection
  • Next by thread: make new as alias
  • Index(es):
    • Date
    • Thread