At 13:15 -0800 2002.04.02, Andrew O. Mellinger wrote: > Can someone give me the quick rundown on how to use properties from >Mac::Glue? > > For example, I'm using the Finder. How do I find the name of the >startup disk? In AppleScript it is: > > tell application "Finder" > return Startup Disk as text > end tell > > What would the be in Mac::Glue? > >I've tried playing around with $glue->prop, $glue->get, and $glue-obj >and I can seem to get the name out. I suppose part of my problem is >that I'm not really sure what $glue->prop, $glue->get do, and how >they differ. > > Does anyone have an tips?
prop and get are not really related, but prop and obj are. In AppleScript, you always need to specifically "get" something to retrieve its value. This is the case in Apple events too, but AppleScript hides it. So when you say: tell app "Finder" to set myVar to name of startup disk You are really saying: tell app "Finder" to set myVar to get name of startup disk Which looks like (using Capture AE control panel): >Process("Finder").SendAE "core,getd,'----':obj {form:prop, >want:type(prop), seld:type(pnam), from:obj {form:prop, want:type(prop), >seld:type(sdsk), from:'null'()}}" AppleScript performs a "get" event and retrieves the name. Mac::Glue makes you do that on your own, so no unintended actions are performed by merely constructing a Mac::Glue object descriptor record. So instead: #!perl -w use strict; use Mac::Glue; my $f = new Mac::Glue 'Finder'; my $obj = $f->obj(property => name => of => 'startup disk'); print $f->get($obj); Now, there are two things to note here, aside from the aforementioned need to call the explicit get() where AppleScript makes it implicit (in some contexts). First is that prop() is merely a synonym for obj(property => ): my $obj = $f->prop(name => of => 'startup disk'); Second is that the special word "of" (like "in") is also a synonym for "property", because, as you can see in the Capture AE output, you are really asking for "property name of property startup disk", since both "name" AND "startup disk" are properties. So "of" allows us the extra syntactic sugar. Note that if you are asking for the name of some class object, instead of a property, then you don't need the extra "of", as the commas take their place, like: my $obj = $f->prop(name => disk => 1); Hope that helps, -- Chris Nandor [EMAIL PROTECTED] http://pudge.net/ Open Source Development Network [EMAIL PROTECTED] http://osdn.com/