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

[MacPerl-Modules] Mac::Glue FileMaker demo



I got this to work today.  I think it is pretty cool.  :)  Note that for
many reasons, it won't work with the current glue module you have now.  :)

#!perl -w
use Mac::MoreFiles;
use Mac::Glue qw(:all);
use strict;

my $finder = new Mac::Glue 'Finder';
my $fm = new Mac::Glue 'FileMaker Pro';

$finder->activate;

my $file = $finder->choose_file(
    {with_prompt => 'Select a FileMaker Pro file (a small one!)'}
);

# use Finder to open ... opening from FileMaker opened
# database with no records ... ?
# reply set to make sure we wait until it is open
$finder->open($finder->obj(file => $file), {_reply => 1});

my $all = obj_form(formAbsolutePosition, typeAbsoluteOrdinal, kAEAll);

my @fields = $fm->get( $fm->prop(name => fields => $all, database => 1));

my @data = $fm->get( $fm->obj(records => $all, database => 1));

set_format(@fields);

my @temp;
foreach (@data) {
    @temp = @$_;
    write;
}


sub set_format {
    my @fields = @_;
    my $f;
    $f  = "format STDOUT_TOP = \n"
        . join('  ', map {sprintf("%-10.10s", $_)} @fields) . "\n"
        . ('-' x (12 * @fields)) . "\n"
        . ".\n\nformat STDOUT = \n"
        . join('  ', map {'@<<<<<<<<<'} @fields) . "\n"
        . join(', ', map {"\$temp[$_]"} 0 .. $#fields)
        . "\n.\n";
    eval $f;
    die "Format failed: $@\n$f\n" if $@;
}

__END__

It returns with:

Category    Date of Re  Receipt Fo  Paid To     Amount
------------------------------------------------------------
Meals       95.04.07    Lunch with  The Deli    $22.65
Parking Fe  95.04.08    Parking     The Parkin  $13.68
Cleaning S  95.04.18    Window Cle  General St  $3.58
Meals       95.04.19    Lunch with  The Deli    $23.49
Postage     95.05.01    Stamps      Post Offic  $42.00
Tolls       95.05.01    Bridge Tol  City        $3.00
Transporta  95.05.06    Taxi        Cab Compan  $12.50
Meals       95.05.25    Lunch with  The Deli    $19.95
Office Sup  95.05.27    Printer Pa  The Office  $9.99
Office Sup  95.05.28    3 ring Bin  The Office  $5.95
Office Sup  95.05.30    Fax Paper   The Office  $9.98


So, how do you like the program syntax (aside from the format stuff :)?
I plan on making that $all thing a special constant that can be exported
(like glueAll).  I am still a few days away from another release ... feel
free to comment on anything you've got now, or anything you see here.

Note that o and p are now obj and prop, and that you no longer need to call
->get to get the data.

Another release will take a little bit longer than I had hoped because I
have several modules to include: Mac::Glue, of course, and updated versions
of Mac::Memory, Mac::AppleEvents, Mac::AppleEvents::Simple, etc, so I need
to clean everything up a bit, stay organized, etc.

--
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