Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / March 2007



Tip: Looking for answers? Try searching our database.

X code & read from file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nope-75644@mypacks.net - 27 Mar 2007 22:06 GMT
I am trying to incorporte this handler into an Applescript studio
application using X code. I understand from the documentation that
this is a low level handler and that the Plain Text Editor sample uses
the hook.

This snipped from the documentation:

>> The Plain Text Editor sample application (distributed with AppleScript Studio, starting with version 1.2) demonstrates how to read and write simple text files with the low-level handlers read from file and write to file, including opening and closing a document file. <<

However, I am stymied as to how to enable this hook to a new
Applescript Document project. Of course the sample
Document.applescript includes the wrapper (routine) and it works
exactly as I want, but it is not clear how to make a new project aware
of this handler. I tried copying and pasting which, of course, didn't
work.

Where does this low-level handler get enabled?

Thanks!
matt neuburg - 28 Mar 2007 03:23 GMT
> However, I am stymied as to how to enable this hook to a new
> Applescript Document project. Of course the sample
[quoted text clipped - 4 lines]
>
> Where does this low-level handler get enabled?

There is no "low-level handler" that "gets enabled". The document
architecture already includes "read from file" and "write to file"
events; you implement those handlers to do whatever you want. The "open
for access" and "read" and "write" commands are standard AppleScript
osax commands (see my book if you don't know AppleScript).

m.

Signature

matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

bzohn - 28 Mar 2007 16:12 GMT
> <nope-75...@mypacks.net> wrote:
> > However, I am stymied as to how to enable this hook to a new
[quoted text clipped - 19 lines]
> AppleScript -http://www.amazon.com/gp/product/0596102119
> Read TidBITS! It's free and smart.http://www.tidbits.com

I am not asking how to trigger the "read from file" and "write to
file" events. I want to know how to insert my own applescript code
when a user chooses to open or save a file in an xcode applescript
document application I am trying to create. The Plain Text Editor
sample application provided with XCode contains a handler in the
Document.applescript file that begins "on read from file." It works
exactly the way that I want. When I create a new xcode applescript
document project, that handler is absent from the Document.applescript
file. If I simply add the handler, it doesn't work. How does one get
that handler to work in the Document.applescript file (or any
applescript file for that matter)?
matt neuburg - 28 Mar 2007 16:53 GMT
> I am not asking how to trigger the "read from file" and "write to
> file" events.

Yes, you are.

>I want to know how to insert my own applescript code
> when a user chooses to open or save a file in an xcode applescript
[quoted text clipped - 6 lines]
> that handler to work in the Document.applescript file (or any
> applescript file for that matter)?

Well, do you know how to make it so that when the user clicks a button
in the interface, your "on clicked" handler is called? In Interface
Builder, you check the "clicked" event handler's checkbox in the
AppleScript Inspector for that button, and you make sure to specify that
the event should be routed to the desired script file. (Again, if you
don't know what I'm talking about, see my AppleScript book, which has a
substantial section devoted to AppleScript Studio.)

It's exactly the same for "read from file".

You yourself started by citing the "Plain Text Editor" example. Well,
look at the example! Open Document.nib and examine the File's Owner in
the AppleScript Inspector.

As the docs explain, it usual to enable "data representation" and "load
data representation", and that is how a default AppleScript Document app
comes configured. But you can use "read from file" and "write to file"
instead if you like. m.

Signature

matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/
Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
AppleScript - http://www.amazon.com/gp/product/0596102119
Read TidBITS! It's free and smart. http://www.tidbits.com

bzohn - 28 Mar 2007 17:55 GMT
> > I am not asking how to trigger the "read from file" and "write to
> > file" events.
[quoted text clipped - 36 lines]
> AppleScript -http://www.amazon.com/gp/product/0596102119
> Read TidBITS! It's free and smart.http://www.tidbits.com

Okay, found it. File's owner is the answer I was looking for. Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.