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

[MacPerl] Frontier and MacPerl revisited



I thought Chris Nandor's reply to my problem with passing a MacPerl variable
onto Frontier had solved all my problems, but it turned out it didn't. I
found more! 

I thought my problems were solved because when i tested this line of code:

$time="April 4, 1998;21:47:00";

then passed the $time variable on to the Frontier portion of the script:

clock.set("$time");

it worked; that is, Frontier set the Mac's clock to the value contained in
$time. The script no longer failed here. This suggested to me that the $time
variable was now being properly interpolated.

However, on further testing, i discovered that if i assigned a date/time
value to $time by using the  net::time module instead of hand assigning it,
then massaged it into the same shape as the example that worked above where
i had hand-assigned it (of the format "Month date, YEAR;HR:MIN:SEC"), the
clock.set() part of the script would now _fail_.

The error message i get is "# OS error -1753 (Error message text not
available)."

You might think that i must not be translating the date/time data right,
that somewhere i'm getting the format wrong to the point where it doesn't
match Frontier's syntax requirement for clock.set() and so clock.set is
failing. I thought that, too, except that i have the script print the $time
to STDOUT before running the Frontier portion of the script, and when I
examine the print "$time" output, and cut and paste that output into
Frontier directly and run clock.set() using that output, Frontier sets the
date and time correctly. This suggests to me that the format is fine.

So combined with confirmation from my first test that Frontier is
interpolating the Perl variable properly, and from my second test that I'm
massaging the date/time info into a form that Frontier can handle, I can't
see why Frontier is failing when the variable is being assigned not by hand
but by the net::time module plus my add'l bit of text processing.

I tried replacing the Frontier clock.set() verb with Frontier's msg() verb
(kind of Frontier's print). That succeeds and fails, too, in the same way.

I can't figure out where i'm screwing this up. Any ideas?

Thanks,

Ben

====
use Net::Time qw(inet_daytime);
use Mac::OSA;
use Mac::Components; 
use Mac::AppleEvents; 

my($frontier, $script, $result, $time);

$time = inet_daytime('[ip address of our internal web server here]'); 
$time =~ s/[\015\012]//g;
$time =~ s/^.+?, //; # get rid of day of week and space after so string
starts w/month

# replace space btw date and time w/semicolon
$time=~s/(19\d\d) /$1\;/;

print "$time\n"; # so i can visually examine the results of the above text
processing

$frontier = OpenDefaultComponent(kOSAComponentType(), "LAND") or die
"Frontier not installed";

$script = AECreateDesc "TEXT", $ARGV[0] || <<"END_SCRIPT";#tried w "" and
without surrounding END_SCRIPT
clock.set("$time");
END_SCRIPT

$result = OSADoScript($frontier, $script, 0, "TEXT", 0) or die $^E;
print AEPrint($result), "\n";
AEDisposeDesc $result;
AEDisposeDesc $script;

CloseComponent $frontier;



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch