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

Re: [MacPerl] Open and open terms in MacPerl



At 09:02 1999-03-23 -0500, Paul J. Schinder wrote:
>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.

I could probably persuade the people in charge of the app to let
me try that, so I will if I 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.

It is, but the dialog box was just my idea of a simple thing to do
with AppleScript. That was part of a test case for *another* bug,
where doing *any* AppleScript in the MacPerl MPW tool would cause
the Mac to die horribly. It was only when I got past that bug that
I found this one.

>} 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.

I downloaded some of Chris's modules, but I can't install them: I get
a message about how they need to be under the MacPerl source directory.
Just moving their folder into the source folder doesn't help. It may be
that I need to be able to compile MacPerl, but that involves buying
MetroWerks (or porting MacPerl to MPW, and I'm desperate enough to have
considered even *that*).

>} 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.

Is there any way to emulate that in MacPerl?

I think I will actually try to lift the embedded Perl script out of
our source control app and turn it into a reusable module, in fact,
but this whole business with AppleScript has taken up so much of my
time and energy that I would like to get something out of it, even
if it is only knowledge. So, out of intellectual curiosity and for
future use, some questions:

- what does MacPerl do while it's waiting for a reply to an event?
Is there an idle handler, or does the script need to provide one?
For that matter, what do MPW or AppleScript do?

- how does MacPerl decide whether or not there's anything to go into ARGV?

I'm looking for answers in the code, but haven't found them yet.

PEter.



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