Re: What's the correct way to insert text into a script at the current insertion point?
Re: What's the correct way to insert text into a script at the current insertion point?
- Subject: Re: What's the correct way to insert text into a script at the current insertion point?
- From: Eric Saunders <email@hidden>
- Date: Fri, 9 Apr 2010 14:30:50 -0400
Remove the if statement. I think you can consider a selection of "" to be, in fact, the selection, so this should work as you need it to:
set dd_mmm_yyyy to (do shell script ("date \"+%e-%b-%Y\"") as text)
tell application "Script Editor"
tell front document
set the selected_text to contents of selection
set contents of selection to dd_mmm_yyyy
end tell
end tell
Eric
On Fri, Apr 9, 2010 at 2:08 PM, Jim Brandt
<email@hidden> wrote:
What's the correct way to insert text (using a script) into a script at the current insertion point? I've tried this script:
set dd_mmm_yyyy to (do shell script ("date \"+%e-%b-%Y\"") as text)
tell application "Script Editor"
tell front document
set the selected_text to contents of selection
if the selected_text is "" then
copy dd_mmm_yyyy to before insertion point
else
set contents of selection to dd_mmm_yyyy
end if
end tell
end tell
If something is selected, the script works.
If something is not selected, all I get is a beep. Since it's the script editor I'm trying to script, I can't run this with a log going, so I can't see what the error is.
So what is the accepted way to copy text to any text-based editor at the current insertion point?
For the record, I've looked at the various scripts written for the Script Editor that Apple supplies. They seem overly complicated and hard to understand.
TIA,
Jim Brandt
_______________________________________________
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
This electronic message contains information from MeadWestvaco Corporation or
subsidiary companies, which may be confidential, privileged or otherwise protected
from disclosure. The information is intended to be used solely by the recipient(s)
named. If you are not an intended recipient, be aware that any review, disclosure,
copying, distribution or use of this transmission or its contents is prohibited. If you
have received this transmission in error, please notify MeadWestvaco immediately
at 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