Originally private mail, Jeff said I could post the response to the list. At 10.30 -0400 1999.06.17, Jefferson R. Lowrey wrote: >pod2html flaw?: > >http://pudge.net/macperl/Mac-Glue-docs.html >Changed function names: <glueInsertion> is now location, glueRange is now >range. I fixed it locally, thanks. There are a few more of those, too. >use Mac::Glue ':glue' > You have a section on the exports that Glue provides. But I still think >you should have a note (even if just "see Exports for more info") about >having to explicity export the glue constants when you are introducing the >glue constants. OK. >Portability >It would be nice to have some comments about how portable glues are, as >well. Something that talks about these kinds of questions: >1) can I move a glue file from one MacPerl installation to another, and >have it work? This question has yet to be answered completely. The basic answer is "for the same architecture (powerpc or cfm68k) and the same version of the same app, yes." A script might depend on more than one app and scripting additions and dialects that may not work across machines. Same as AppleScript. I am not sure how to mark glues for version info yet. i.e., my $bb = Mac::Glue->new('BBEdit', {REQUIRE => '5.1'}); # maybe ? But you're probably just talking about same version of the same app on another machine, and the answer is that as long as they are both PPC or both CFM68K, it should work just fine. There is nothing specific about the machine kept in the glues, only architecture-specific methods of creating and using them. >2) Can I pass a glue object to a remote MacPerl program? That is, >supposing I have the same glue files on both machines, can I instantiate on >machine A and pass to machine B? I can't think of situations where this >would be useful, but it might be cool. Yes. You would need to get the actual data from the handle. Objects in Mac::Glue are returned as AEObjDescs, which store the actual AEDesc in the DESC key. The AEDesc is really a Handle, and you can get the actual Handle with the data method, which has its data returned fromt he get method. This you can store. $obj = $glue->obj(foo => 1); $data = $obj->{DESC}->data->get; Here is an example of storing an AEDesc and using it again after retrieving it. #!perl -w use Mac::Glue ':all'; use strict; my($f, $obj, $data, $handle, $file, $desc); $f = new Mac::Glue 'Finder'; $obj = $f->obj(item => 1); print $obj->{DESC}->get, "\n"; # object print $f->get($obj)->{DESC}->get, "\n"; # get it! $data = $obj->{DESC}->data->get; # get actual raw data $file = "Bourque:Desktop Folder:handle"; # save data open(FOO, "> $file") or die $!; print FOO $data; close FOO; # get data back open(FOO, "handle") or die $!; { local $/; # slurp mode $handle = new Handle <FOO> or die $^E;} close FOO; # put data in new handle $desc = new AEDesc typeObjectSpecifier, $handle; print $desc->get, "\n"; # object print $f->get($desc)->{DESC}->get, "\n";# get it! __END__ It _should_ work between machines too. You could send the raw handle data over files, sockets, whatever. I am not sure what to do about AEObjDescs yet. I was considering allowing you to use ->get and ->data directly on them, but I am also considering allowing you to use them as targets directly ... I just don't know yet. You can also talk directly to other machines directly. For instance, I should be able to create an AEDesc referring to text body of document 1 of AppleWorks, and then send an event with that object to another machine. The problem is that right now, you really can't use Mac::Glue to talk to another machine. You can do it with Mac::AppleEvents, though, and so you can create an object in Mac::Glue, and send it with Mac::AppleEvents to another machine. Here is a quick example. The glue creates an object to refer to the contents of the front document in BBEdit, then gets the contents locally and remotely. #!perl -w use Mac::Glue ':all'; # includes Mac::AppleEvents my $bb = new Mac::Glue 'BBEdit'; $bb->activate; my $obj = $bb->prop(contents => document => 1); print $bb->get($obj); # only way to get remote target right now, that i know of my $remote = $bb->choose_application(RETOBJ => 1)->data->data->get; Mac::Apps::Launch::SetFront('McPL'); open WINDOW, ">Dev:Console:Remote Machine" or die $!; # only way to specify remote target right now my $evt = AEBuildAppleEvent(qw(core getd), typeTargetID, $remote, 0, 0, '') or die $^E; AEPutParamDesc($evt, keyDirectObject, $obj->{DESC}) or die $^E; my $rep = AESend($evt, kAEWaitReply) or die $^E; my $do = AEGetParamDesc($rep, keyDirectObject) or die $^E; print WINDOW $do->get; AEDisposeDesc $evt; AEDisposeDesc $rep; AEDisposeDesc $do; __END__ I believe there is a bug in MacPerl's Socket routines for packing PPC sockets, so there is no Good Way of doing this yet. However, I think I am going to add the code into Mac::AppleEvents::Simple and Mac::Glue to accept a TargetID as the target, so you could do this instead: #!perl -w use Mac::Glue; my $bb = new Mac::Glue 'BBEdit'; $bb->activate; my $obj = $bb->prop(contents => document => 1); print $bb->get($obj); # only way to get remote target right now, that i know of my $remote = $bb->choose_application(RETOBJ => 1)->data->data->get; Mac::Apps::Launch::SetFront('McPL'); open WINDOW, ">Dev:Console:Remote Machine" or die $!; # this replaces everything from AEBuildAppleEvent on down # doesn't work yet :) print WINDOW $bb->get($obj, TARGET => $remote); __END__ It wouldn't take too much work, but it is not slated for any upcoming release, and it has been on my list for awhile now. The fact that you cannot pack a PPC socket without using the choose_application event is part of why I haven't done it yet. >3) Are Glues tied to particular copies of applications - this is mostly the >same as the first question. If I make a glue from one machine, and move it >to another - is it going to be looking for the application in the same >place as on the other machine? It finds apps via their creator ID, so location is not important. I am thinking of adding a way to specify specific location in the Mac::Glue->new() constructor, so in the future you can choose a particular app if you have more than one of the same creator ID. # doesn't work yet :) $bb = Mac::Glue->new('BBEdit', {PATH => 'path:to:BBEdit'}); This is part >TIMEOUT > You say that the default timeout is hundreds of seconds. This is not >true of timeouts within AppleScript. Do you explicitly set the timeout to >some large number in your generic glue event sender? I used to. I noted in the HISTORY that timeout is now infinity by default. I used to set it to some large number. You can override it with $glue->TIMEOUT(SECONDS) or $glue->EVENT(DOBJ, PARAM => DATA, TIMEOUT => SECONDS). -- Chris Nandor mailto:pudge@pobox.com http://pudge.net/ %PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6']) ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org