Re: Slow app with Fusion drive.
Re: Slow app with Fusion drive.
- Subject: Re: Slow app with Fusion drive.
- From: Shane Stanley <email@hidden>
- Date: Wed, 13 Mar 2013 09:33:50 +1100
On 13/03/2013, at 6:42 AM, Paul Berkowitz <email@hidden> wrote:
> In the code you provide to Brian, you appear to be dealing with AppleScript as used in (Apple)Script Editor and other script editors, not in Xcode, although these two classes you refer to here – NSFileManager and NSURL – must be as accessed via AppleScriptObjC? So, although you don't say so, I thought that might mean you'd be using your own ASObjC Runner to be able to do that. But when I check your sample code on your website, all such uses require a 'tell application ASObjCRunner"' block somewhere, which your code for Brian doesn't. These classes appear to be available as part of 'current application's, whatever current application turns out to be, so as part of general AppleScript terminology somehow.
Confusing, isn't it. They are snippets of compiled AppleScriptObjC code, which is really just normal AS code, and they can be used in several places:
* In a Cocoa-AppleScript application written in Xcode in OS X 10.6 or later. Because recent versions of Xcode don't have a built-in AS editor, the formatting looks like the code Brian has posted. It's appalling (multi-word terms get their words colored differently, for example), but it gets compiled the same as any other AppleScript code, and you can use any AS editor as an external editor to view it properly.
* In a Cocoa-AppleScript app saved from AppleScript Editor. This was only added to ASE in 10.7, but it can actually be done manually in 10.6; it just inserts a .scpt file containing ASObjC code into a Cocoa app bundle where a pre-written ASObjC class loads it and calls its run and/or open handlers.
* In ASObjC Runner, inside a script object to be passed to its 'run the script' command. Needs 10.6 or later.
* In AppleScriptObjC Explorer, which will run the code "natively", and can save it in the form of an app similar to those saved from ASE. 10.6 or later.
So I could have been doing it in any of these; in fact it was the latter, because that's the only one that provides logging and lets you simply test snippets of code.
The Xcode method involves a script object that gets loaded at run time as an Objective-C class to do its magic. The rest have a built-in ASObjC class that gets loaded, and use AS's 'load script' command (or equivalent) to load the code you write on the fly; when 'load script' is used in an ASObjC script, the loaded script can also include ASObjC code. The ASObjC Runner method is the only one that doesn't produce stand-alone code.
As for 'current application', it's used all the time, as you can see. It's essentially a way of getting out of the scope of the script object the code must be part of (but which may not be visible in the non-Xcode stuff). So to use a Cocoa class or enumeration, you precede it by 'current application's' and it all just works. Methods are then called as if they are normal AS handlers, with a couple of quirks.
>
> Could you please fill in the missing bits for me, or direct me somewhere where I can read about it? Don't worry, if I have any time to delve into this once I get my new iMac, I'll get your book for sure, but in the meantime I'm curious just to know where this terminology is coming from, and how to access it. And is it available as of OS 10.6, or only a later OS than that?
It's really not as hard as it may look; the initial steps are a bit of a shock, plus coming to grips with documentation aimed at people writing in Objective-C and comfortable with C. But the potential rewards are enormous. I remember when 'do shell script' was introduced, and how it opened enormous possibilities. To my mind, this stuff is an order of magnitude bigger. And no more death-by-display-dialog...
--
Shane Stanley <email@hidden>
'AppleScriptObjC Explored' <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