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

Re: [MacPerl] Suggestion for a MacPerl Extension



Paul Schinder writes on 14-JUL-1996:

!PVHP@LNS62.LNS.CORNELL.EDU writes:
!} 
!}  my $quit = 2;
!}  $decision = MacPerl::Answer(
!}     "Fire up a web browser now to look at\n$file\n?", "OK", "Skip", "Cancel");
!}  if ($decision != 2) { 
!}      &MacPerl::Quit($quit); 
!
!You realize that MacPerl::Quit does not actually quit, but sets a flag
!that determines what MacPerl does when it hits an exit?  You want an
!exit() here.  I usually put my MacPerl::Quit at the very beginning of my
!scripts.

I did not know that. The way I had it written the call to &MacPerl::Quit(2);
seemed to exit all of MacPerl (I used it in more than one location - with 
branching dependent on user input). In fact I found that debugging was made 
easier by the ability to switch the integer values I used in the $quit 
variable. Were this to run as a pure perl cron job (perhaps it won't given 
your comment below) I would not have set $quit to 2 but either 1 or 3 (or 
something). Thanks for the tip.

!}      my $script = 
!}      "tell application \"$browser\"\n".
!}      "       GetURL \"file://$localhost/$tmp_folder_slashed/$file\"\n".
!}      "          activate\n".
!}      "end tell\n";
!}      &MacPerl::DoAppleScript($script);
!} 
!} OK so here are my questions: 
!} 
!} 1) Is there a way to call Internet Config to fire up the browser & look at 
!}    the localhost file? Scripting like that would seem to 
!
!Not that I know of, but you realize that, with the way Applescript
!works, it'll ask you where $browser is the first time you run it on a new
!machine anyway?  Getting it not to ask is a pain, because, as far as I
!can tell, you need to use the Script Editor once with the same syntax to
!get the application selected automatically.  You'll wind up hand editing
!the script anyway.

Yes - precisely what I was trying to avoid (hand editing script, & perhaps the 
use of the $browser variable altogether) through some (apparently non-existant)
call to Internet Config directly from perl. The set up I had in mind assumes 
that I will get a chance to install MacPerl and configure Internet Config for 
'file://' URLs on the other machine.

!} 2) How do I write cron jobs in MacPerl? Assuming I call perl builtins like 
!
!Although you can probably do it in MacPerl, the easiest way is to use
!one of the Macintosh crons.  You can find them in the Info-Mac archives.
!I like Mark Malson's because of the simplicity of the way it works, but
!the others have their own features.  I cron launch MacPerl scripts
!several times a day.

OK - that is fine for my purposes. I'll look into it and thank you very much 
for the tip.

!(Incidentally, I got my Ph. D. in Physics at Cornell.  Spent a lot of
!time in Clark, Newman, and Rocky Barracks, which some know as
!Rockefeller Hall)

Well you don't have to tell us which year but I am sure it hasn't changed too 
much since that time! I work mostly at Wilson Synchrotron Lab.

Peter Prymmer
pvhp@lns62.lns.cornell.edu