At 7:25 pm -0400 10/04/01, Morbus Iff wrote:
>Good day, all. Currently, in a script of mine, I use the following code to
>launch the default browser on the users' machine to a specific URL:
>
> use Mac::InternetConfig qw(:DEFAULT $ICInstance);
> ICGeneralFindConfigFile($ICInstance);
> ICLaunchURL($ICInstance, 0, $url);
>
>What I'm looking to do is give the user a choice besides their default
>browser - they'd pass the full file path to the browser in question. I, in
>turn, would instruct that file/app to open $url.
>
>Is this possible? I had looked into exec and system and they didn't seem to
>provide what I needed (if I'm wrong, let me know). I saw mention of
>Mac::Processes::LaunchApplication, but couldn't get it to work and then
>read on that it doesn't pass command line parameters.
>
>Can I do this with some sort of Glue function? Can someone give me a demo?
>
>Ultimately, I'm looking to duplicate the following:
>
> unless( fork ) { exec("/usr/local/mozilla/mozilla $url");
>
>Thanks!
The following will launch Netscape for instance:
#!perl
use Mac::MoreFiles;
use Mac::Processes;
LaunchApplication(
LaunchParam->new(
launchControlFlags => launchContinue(),
launchAppSpec => $Application{'MOSS'}
)
);
However the MacOS version of your program will be in the form of a
"runtime" -- right? So the problem is how to get the creator string
('MOSS', 'MSIE' or whatever) into the program?
You could, on launching the runtime, put up a dialog with
MacPerl::Ask() and set a global variable;
$SETTINGS->{creator} = MacPerl::Ask("Enter browser creator type", "MOSS");
and then proceed to the browser launch above.
You could also perhaps think of a 'Prefs' file in (in
<:data:internal:>, say) which could hold the creator string. If there
is nothing in the file put up the dialog otherwise use the preference.
However that would not seem to me to offer much advantage over the
default Mac arrangement. It is after all very easy to change the
default browser type in InternetConfig by the 'Internet' Control
Panel. It strikes me it might be unlikely the user would choose a
different browser for your program than the one he or she regularly
uses? But maybe I've missed a point here.
It would also be possible to use to edit the 'Prefs' file via a custom MenuBar.
HTH,
Alan Fry