Re: sending data from one AppleScript App to another
Re: sending data from one AppleScript App to another
- Subject: Re: sending data from one AppleScript App to another
- From: Paul Berkowitz <email@hidden>
- Date: Wed, 03 Sep 2003 12:10:04 -0700
On 9/3/03 11:22 AM, "Michael Glasser" <email@hidden> wrote:
>
Ok... what am I *really* doing...
>
>
I am making an AIM bot... not a porn bot or anything like that, just
>
one to respond to people in a semi-"human" way.
>
>
I have a script that AIM runs every time it gets a message. I need to
>
keep that one very quick, if not, AIM slows to a crawl.
>
>
I found a solution to this... the AIM script sends data to a buffer,
>
currently a TextEdit file. Another script (my Bot script) reads from
>
the buffer, processes the text, and, if needed, sends a response back
>
to AIM.
>
>
I am looking into having the buffer be another script... one that is
>
sent data from the AIM script and has data gathered by the Bot script.
>
>
Would this be faster? If so, any ideas on the best way to do it?
Make your buffer a text file - not a TextEdit document. Writing to and
reading from text files with the write and read Standard Additions is
tremendously fast. You can set the location of the file so that it will work
for everyone. For example:
set appSupportPath to path to application support from user domain as
Unicode text
try
set myAppSupportFolder to alias (appSupportPath & "My App Name:")
on error -- first time
tell application "Finder" to set myAppSupportFolder to make new
folder at item appSupportPath with properties {name:"My App Name"}
end try
set myBufferFilePath to (myAppSupportFolder as Unicode text) & "My App
Name Buffer.txt"
set fileRef to open for access file myBufferFilePath with write
permission -- makes it if first time
set eof fileRef to 0 -- only if rewriting every time
write "Whatever you're writing" to f starting at eof -- 'starting at
eof' if continuing on
close access fileRef
If the other file just needs to read it, it can
set r to read alias myBufferFilePath
without even opening for access. If it needs to read, add some more text,
then write back to teh file, then after pening for access with write
permission in the script above:
set r to read fileRef
Then make your adjustments and write back, either after setting eof to 0
(rewrite completely), or starting at eof (continuing on).
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.