• 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
What's the correct way to insert text into a script at the current insertion point?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's the correct way to insert text into a script at the current insertion point?


  • Subject: What's the correct way to insert text into a script at the current insertion point?
  • From: Jim Brandt <email@hidden>
  • Date: Fri, 9 Apr 2010 13:08:23 -0500

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
  • Follow-Ups:
    • Re: What's the correct way to insert text into a script at the current insertion point?
      • From: Eric Saunders <email@hidden>
  • Prev by Date: Re: Passed test but Script Editor fails was Re: Spurious Apple Event Timeout Fixed in 10.6.3?
  • Next by Date: Re: What's the correct way to insert text into a script at the current insertion point?
  • Previous by thread: Re: Passed test but Script Editor fails was Re: Spurious Apple Event Timeout Fixed in 10.6.3?
  • Next by thread: Re: What's the correct way to insert text into a script at the current insertion point?
  • Index(es):
    • Date
    • Thread