On Sunday, December 2, 2001, at 08:11 PM, Wilfredo Sanchez wrote:

>   The potentially surprising event here is that the script is running 
> twice.  I was actually aware of this, but had forgotten.  If the Finder 
> has been written in Cocoa, I think you'd see the script invoked only 
> once, with multiple arguments.  This would almost certainly be the case 
> if you build and run DropScript on Rhapsody.
>
>   What's going on is that the Carbon pasteboard is somehow unclever, 
> and doesn't accept multiple items or something like that.  The upshot 
> is that Finder sends two open: requests to the drop application and not 
> one with two file names.
>
>   I think this is what's tripping you up.  Your test ends up 
> overwriting the log file on the second invocation, so you only see the 
> last file name received.  If you were to append, I think you'll see 
> both.
>
>   This is actually a big problem...  It means that DropShove probably 
> doesn't work, because it will only archive one file.  That sucks.

I don't know where/when this API bigotry started, but I wish it would 
stop.  Let's make Mac OS X great and stop bickering about whose API is 
better than the other guys, or that the a particular problem is the 
result of Carbon vs. Cocoa, and instead, let's just fix the problem.

This has nothing to do with Carbon - it has to do with how AppKit 
dispatches odocs and how DropScript is written.  From the DropScript 
source:

- (BOOL) application: (NSApplication*) anApplication
            openFile: (NSString*     ) aFileName
{
   if (myAppIsLaunching) myAppWasLaunchedWithDocument = YES;

   [self runScriptWithFiles: [NSArray arrayWithObject: aFileName]];

   return YES;
}

So for every file that you get a message for, you run the script.  The 
end result, that the script is invoked N times, shouldn't be surprising 
to anyone.

I've fixed DropScript to do the right thing.  I'm not a regular 
contributor to Darwin so please tell me who/where to send the patch so 
the problem will be fixed for users of the software.

[Although I am subscribed to this list under my company address, I am 
speaking for myself and fixed this of my own volition, not that of my 
employer, yadda yadda yadda...]

Jim

Reply via email to