[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Open and open terms in MacPerl



On Tue, Mar 23, 1999 at 01:37:41PM +0000, Peter Westlake wrote:
} 
} This is the same problem that I posted about a little while ago.
} I have a source control program which is actually MacPerl 5.1.3r2

Terribly old, if you have the version right.  Upgrade it to MacPerl
5.2.0r4 if you can.

} with an embedded script, which either puts up a window for interaction
} or goes off and does something by itself depending on how it is
} invoked. If a file is dropped onto the app, Perl puts the filename
} into @ARGV and the script detects this and runs in batch mode. If
} there isn't anything in @ARGV, it runs interactively. It works if

Is this the script that went by in the last few weeks that used
AppleScript to grab the filename with a dialog box?  If so, why don't
you just use MacPerl::Ask?  Simple dialogs are built into MacPerl.

} I drop a file onto the app's icon, and it works if I use MPW to
} invoke the app by its path, with the filename as a parameter. But
} life would be much simpler for me if I could just call this app
} from a Perl script. MacPerl doesn't have system(), so I'm trying
} to use AppleScript to call the app, using "launch" and "open file".

No, but modern MacPerl can send an AppleEvent directly, and Chris
Nandor has been working to make this much easier to do than it is by
using only the stuff that comes with MacPerl.

} This is in a Perl script running in MacPerl 5.2.0r4, just to confuse
} matters. Now, sometimes it works, but sometimes the app puts up its
} interactive window, as if it hadn't been given a file to open.
} 
} Let's just check that I understand how all this is meant to work,
} since I've never written a Mac program in my life! I gather that
} dragging a file onto an application is implemented by the Finder
} starting the application and sending it an 'odoc' AppleEvent.

That's the way I understand it happens.

} If so, then I wonder if this could be a timing problem, with the
} app sometimes getting to the ARGV code before the AppleEvent has
} come in and set up @ARGV? But then how do MPW and the Finder manage
} to get it right?

Timing problems are endemic in AppleScript.  There's no way to
reliably control flow in AppleScript.  MPW and the Finder seem to have
more control over the raw AppleEvents than AppleScript lets you have.

} 
} Peter.
} 
} 
} 
} 

-- 
Paul Schinder
schinder@pobox.com

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org