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

[MacPerl] "William B. Birkett": AppleEvents parameter string problem




------- Forwarded Message

Return-Path: wbirkett@pcolor.com 
Delivery-Date: Wed, 28 Oct 1998 01:56:32 +0100
Return-Path: wbirkett@pcolor.com
Received: from pcolor.com (pcolor.com [207.238.181.66])
	by iis.ee.ethz.ch (8.8.8/8.8.8/IIS-zinal-ak-2.2) with SMTP id BAA19097
	for <owner-mac-perl@iis.ee.ethz.ch>; Wed, 28 Oct 1998 01:56:30 +0100 (MET)
Received: from [207.238.181.83] by pcolor.com (AppleShare IP Mail Server 6.0) id 78887 via TCP with SMTP; Tue, 27 Oct 1998 20:56:33 -0400
X-Sender: wbirkett@207.238.181.66
Message-Id: <l03130300b25c137495ef@[207.238.181.83]>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Tue, 27 Oct 1998 19:56:33 -0500
To: owner-mac-perl@iis.ee.ethz.ch
From: "William B. Birkett" <wbirkett@pcolor.com>
Subject: AppleEvents parameter string problem

I'm working on a MacPerl script which will catalog our library of 4000 CD's
into Cumulus, an image database. A step in the cataloging process is to
create categories (via Apple Events). The AppleScript equivalent of what I
want to do in MacPerl is:

set str to "Visual Services"

tell application "Canto Cumulus Client"
	tell table 2 of database "MacPerlTest"
		set newCategoryRef to (make row at beginning with
properties {name:str, parent:item 0})
	end tell -- table 2 of first database
end tell -- Cumulus

- ----------

This produces the following AE (from Capture AE):

Process("Canto Cumulus Client").SendAE "core,crel,insh:insl{kobj:obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}, kpos:bgng}, prdt:{pnam:"Visual
Services", pIdP:obj {form:indx, want:type(cobj), seld:0, from:obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}}}, kocl:type(crow), &subj:obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}"

- ----------

Using AppleEvents::Simple, I've wrote the following code to accomplish the
same thing:

#!perl -w

use Mac::AppleEvents::Simple;

my($db, $cust, $parent, $ID);

print "makeCUM\n";

$db = 'MacPerlTest';

$cust = 'Visual Services';

# add customer category at root level
$ID = makeCUMdb ($db, $cust, 0);

print "done\n";

# make category in Cumulus database
# usage: $ID = catCUM ($database, $category, $parent);
sub makeCUMdb {
    my ($database, $category, $parent) = @_;

    my $param = q"insh:insl{kobj:obj {form:indx, want:type(ctbl), seld:2, " .
      q"from:obj {form:name, want:type(cDB ), seld:TEXT(@),
from:'null'()}}, " .
      q"kpos:bgng}, prdt:{pnam:TEXT(@), " .
       "pIdP:obj {form:indx, want:type(cobj), seld:$parent, " .
      q"from:obj {form:indx, want:type(ctbl), seld:2, " .
      q"from:obj {form:name, want:type(cDB ), seld:TEXT(@),
from:'null'()}}}}, " .
      q"kocl:type(crow), &subj:obj {form:indx, want:type(ctbl), seld:2, " .
      q"from:obj {form:name, want:type(cDB ), seld:TEXT(@), from:'null'()}}";

    my $evt = build_event(qw/core crel CuCl/, $param,
      $database, $category, $database, $database);
    $evt->send_event();
    return (0); # eventually return the row ID

}

- ----------

The MacPerl code generates the following AE:

Process("Canto Cumulus Client").SendAE "core,crel,insh:insl{kobj:obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}, kpos:bgng}, prdt:{pnam:"Visual
Services", pIdP:obj {form:indx, want:type(cobj), seld:0, from:obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}}}, kocl:type(crow), '&sub':obj
{form:indx, want:type(ctbl), seld:2, from:obj {form:name, want:type(cDB ),
seld:"MacPerlTest", from:'null'()}}"

- ----------

which is nearly correct, but for one small (and fatal) difference. What
should be:

 .... kocl:type(crow), &subj:obj {form:indx ....

is instead:

 .... kocl:type(crow), '&sub':obj {form:indx ....


Does anyone know how to write this parameter string correctly? I've done a
lot of trial and error, and studied the AE Gizmos documentation, but I
can't figure it out.

- -Bill




Bill Birkett
Precison Color, Inc.
Plymouth, MI




------- End of Forwarded Message


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