• 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: Coerce Script to Text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce Script to Text?


  • Subject: Re: Coerce Script to Text?
  • From: Shane Stanley <email@hidden>
  • Date: Sun, 23 Feb 2014 12:31:11 +1100

On 23 Feb 2014, at 6:14 am, Christopher Stone <email@hidden> wrote:

Is there a simple way to coerce data or script to text without resorting to the shell?

Assuming you mean AS data objects, you can write them to a file and read them using read. For a script, you're probably looking at osadecompile, or using OSAScript in an ASObjC-based library (which also gives you the option of getting it as RTF, of that's useful). Something like:

use framework "Foundation"
use framework "OSAKit"

on getSourceFor:scriptPath
set aURL to current application's |NSURL|'s fileURLWithPath:scriptPath
set theScript to current application's OSAScript's alloc()'s initWithContentsOfURL:aURL |error|:(missing value)
return theScript's source() as text
end getSourceFor:


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: 
 >Coerce Script to Text? (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Considering case...
  • Next by Date: Re: Considering case...
  • Previous by thread: Re: Coerce Script to Text?
  • Next by thread: Re: Considering case...
  • Index(es):
    • Date
    • Thread