On Mar 23, 2007, at 10:56 AM, David Cantrell wrote:
On Thu, Mar 22, 2007 at 05:55:18PM -0400, Sherm Pendley wrote:
On Mar 22, 2007, at 1:01 PM, Andrew Brosnan wrote:
I'd like to run a daily backup script on my laptop, but I'd like
it to
ask permission first. I'm wondering what is the best way to do this.
First off - can you always depend on a user being logged in? If so,
the simplest ideas tend to be the best. For a full-blown GUI app I'd
use CamelBones, but for a simple OK/Cancel dialog the old MacPerl
module is still the easiest:
#!/usr/bin/perl
use MacPerl;
my $verify = MacPerl::Answer('Do you want to run backups?', 'OK',
'Cancel');
print $verify, "\n";
Consider what happens if I'm busily typing away, and the dialogue box
pops up and grabs focus, and then whatever its default is gets
selected
because i hit space or enter. So not only have you annoyed me by
popping something up and then removing it before I get a chance to
read
it, you'll now take an action without the user knowing about it but on
the assumption that he does, *and* you've eaten an arbitrary amount of
what I typed, which I'll have to type again.
Needless to say, this is a Very Bad Idea.
If this were something that might pop up at any random moment, I'd
agree. But it's a daily backup script - it's not unexpected, and
presumably it's scheduled to run at the same time every day. Andrew
doesn't need to be notified that it's going to run, he knows that
already; all he needs is veto power over it.
sherm--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net