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

Re: [MacPerl] more quark scripting



At 10.04 -0500 2000.03.31, Bill Birkett wrote:
>In practice, my experience is similar to yours. There are no Glue
>examples for software like Quark, Photoshop, Cumulus, and ColorSync.

I don't use these much or at all.  Examples from others to the list would
be most welcome, and maybe included in the next release.

>Example code would help a lot. But I also think that Glue needs some
>further development to work with these applications. For instance,
>both Quark and Photoshop use floating point parameters for dimensions
>which are type 'doub'. In Photoshop, you must specify dimensions such
>as pixels, inches, and cm's, which are special types. I don't think
>this is possible with Glue - it only handles integer and text values.

Well, it doesn't handle just integer and text.  It uses the aete resource
to guess at the correct type.  If that type is an alias, it will turn a
path into an alias.  If boolean, it will turn your value into a boolean.
However, some types are not defined in Mac::Glue, and some types are ****,
so Mac::Glue has to guess, and that guess will end up being text or integer
(I suppose we could add doub to that guess, too).

You can pass any type you want in various ways.  I added a param_type
function to let you override Mac::Glue's guess at the type:

  $glue->open( param_type($path, typeAlias) );  # force it to convert to alias

As to the other problem, where Mac::Glue does not know the type (imagine
some type "F00B"), you can install a handler for that type.  So if type
F00B is just the data reversed:

  local $AE_PUT{'F00B'} = sub { scalar reverse $_[0] };

You just need to know how to pack that data to put into the AE.  Here is a
real world example, what I do in Mac::Glue itself to convert a path into an
alias:

  local $AE_PUT{typeAlias()} = sub {
    my $alis = NewAliasMinimal($_[0])
      or croak "Can't create alias for '$_[0]': $^E";
    return $alis->get;
  };

(The local() is not required, but I usually use it to make sure I don't
make permanent changes to %AE_PUT (where "permanent" means the life of the
running program), unless I know I want permanent changes made.)

I can add more of these, like I did with typeAlias, to the default
Mac::Glue code.  There is a relatively small set now, that covers most of
the cases.  The larger problem seems to be telling Mac::Glue what type to
use, though, and for that param_type() can be used.

-- 
Chris Nandor       |     pudge@pobox.com      |     http://pudge.net/
Andover.Net        | chris.nandor@andover.net | http://slashcode.com/

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org