Author Topic: Use Automation with PERL  (Read 6021 times)

thomaskilian

  • Guest
Use Automation with PERL
« on: September 24, 2004, 07:25:39 am »
Does anyone have an idea whether it is possible to use EA Automation interface with PERL? I think it should be feasible but I don't know how to make perl aware of EA's COM interface. Any help appreciated  :)

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: Use Automation with PERL
« Reply #1 on: September 24, 2004, 07:41:37 am »
Hi Thomas,

use Perl's Win32::OLE module and the methods NEW, GETOBJECT and GETACTIVEOBJECT. This way you can invoke any OLE/COM.

Hope this helps!
Bruno

thomaskilian

  • Guest
Re: Use Automation with PERL
« Reply #2 on: September 25, 2004, 12:16:34 pm »
Thanks Bruno  :D I'll try that next week :)
BTW: The OLE smiley is nice  ;D
« Last Edit: September 25, 2004, 12:17:25 pm by thomaskilian »

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: Use Automation with PERL
« Reply #3 on: September 25, 2004, 01:10:57 pm »
No problem Thomas, let me know how it went!
The OLE smiley took me by surprise. Sorry :-)

Bruno

thomaskilian

  • Guest
Re: Use Automation with PERL
« Reply #4 on: September 28, 2004, 08:42:37 am »
Hi Bruno,
I found some time in the train to fiddle with PERL - again. Unfortunately half a year has gone since my last battle, so I forgot many things.
 $ea = Win32::OLE->new('EA.App');
actually creates an object, but I can't invoke any method or print any attribute. Any quick hint?

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: Use Automation with PERL
« Reply #5 on: September 28, 2004, 10:04:54 am »
Hi Thomas,

following your example, you need somthing like this:

print $ea->attributeormethod;

Much the same like in, say, Visual Basic, just instead of the dot notation, use ->

Hope this helps!

Bruno

thomaskilian

  • Guest
Re: Use Automation with PERL
« Reply #6 on: September 28, 2004, 03:01:52 pm »
Hi Bruno,
that's exactly what I did, but it does not work. NEW delivers a scalar dereference in $ea and $ea->Repository also. But if I go further nothing is returned (result = undef). Probably I have to go into more detail with PERL. Thanks anyway - I'll be back with news as soon as I get it to work.

thomaskilian

  • Guest
Re: Use Automation with PERL
« Reply #7 on: September 29, 2004, 06:01:51 am »
Hi Bruno,
at last I found the bug. You need EA.Repository not .App. :o
The following code sequence prints the top most package name:
Code: [Select]

use Win32::OLE;

$ex = Win32::OLE->new('EA.Repository', \&OleQuit) or die "oops\n";
$ex->OpenFile("C:\\test.EAP") or die "File not found";
$mo = $ex->{Models};
$mo = $mo->GetAt(0);
print $mo->{Name}, "\n";

sub OleQuit {
   my $self = shift;
   $self->Exit();
}


Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: Use Automation with PERL
« Reply #8 on: September 29, 2004, 09:58:56 am »
Excellent!