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

Re: [MacPerl] Name of drives



In article <367E4C3A.11C4C34D@bms.com>, Geoffrey C Kinnel <kinnelg@bms.com> writes:
> If you want to detect a disk insertion, you could be run an "event
> loop", the archetypal method for writing a Mac program. Basically, it's
> an endless loop:

> <WARNING! coding whilst half asleep, on a machine without Perl>

> while(!$user_quit) {
>   WaitNextEvent();
>   $event=$Mac::Events::CurrentEvent->what();
>   if ($event == dskEvt) {
>     #disk inserted do something here
>   }
> }

That's the basic idea, except that the event loop in MacPerl is implicit, so
what you would do is:

use Mac::Events;

$Mac::Events::Event[dskEvt] = \&DiskInserted;

WaitNextEvent() while ($whatever);

sub DiskInserted {
  # Disk inserted, do something
}

Matthias

-- 
Matthias Neeracher   <neeri@iis.ee.ethz.ch>   http://www.iis.ee.ethz.ch/~neeri
   "I'm set free to find a new illusion" -- Velvet Underground


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