MACSCRPT Archives

November 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 18 Nov 2006 12:41:01 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (58 lines)
Paul Berkowitz wrote:

Won't bother replying to all of this post as I had my fill of vanilla  
AS algorithms long ago, and it's one of the reasons I eventually  
moved to another language. Re. the last bit though:


> Maybe someone even knows another list osax that does
> it? (I've checked has's TextCommands too.)

TextCommands, as the name implies, supplies commands for processing  
text. :)

If you wanted you could easily implement a ListCommands FBA using the  
same sfba framework. For example, the implementation for a 'find  
item' command would be:

from aemreceive.sfba import *

def finditem(itm, lst):
     try:
         return lst.index(itm) + 1
     except ValueError: # item not in list
         raise EventHandlerError(-1728)

installeventhandler(
         finditem,
         'LiCoFind',
         ('----', 'itm', kAE.typeWildCard)
         ('In  ', 'lst', kAE.typeAEList)
         )

starteventloop()


Add an sdef and a setup script, then build as a standalone  
application with a user-installed Python framework. There's a  
tutorial included in the py-appscript documentation.

That said, OSAXen and FBAs aren't ideal for list and record  
processing as all data must be packed into Apple events in order to  
be passed to them. This limits their usefulness since 1. all data is  
copied, so if your list contains sub-lists/records then those will be  
duplicated too (which is not always what you want), and 2. not all  
data is copyable (references to other applications can't be copied at  
all, and copying script objects is almost always a disaster). Packing  
large lists was also impossibly slow in Jaguar and earlier, though  
that's not such an issue nowadays since most Mac users will be  
running Panther or later. But you pays your money and takes your choice.

HTH

has
-- 
http://freespace.virgin.net/hamish.sanderson/
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org

ATOM RSS1 RSS2