Thanks for the help, that clarified things.

/Sam


On Dec 22, 2005, at 12:56 PM, Jan Dubois wrote:

On Thu, 22 Dec 2005, Samuel Meder wrote:

I've written a fairly simple script that creates a few COM object
handles and invokes methods on them (in my case related to managing
Virtual Server). This looks something like:

my $handle = $WScript->CreateObject("Foo.Application");
my $resultingObject = $handle->method();

Now, a call to "method" will sometimes result in a error and no object
will be returned. In that case I can check if $resultingObject is
undefined, but I've not been able to find any documentation about how
to get to the error (which seems to end up in some global/ contextual
object). So the questions I have are:

* Can I get to this error using Win32::OLE->LastError(). Will that mix well with my perlscript use or should I just rewrite the whole thing
  using Win32::OLE calls?

You can just use Win32::OLE->LastError().  Your $handle variable above
is a Win32::OLE object.

* Is the source for the perl <-> WSH glue code available somewhere? I
  downloaded the activatstate perl source dist and couldn't find it
  there.

The Perl <-> WSH glue is really just Win32::OLE under the covers.  The
ActiveX Scripting interface for Perl (called "PerlScript") is just a thin
wrapper around normal Perl and uses Win32::OLE internally.

The ActivePerl sources only include the source for core Perl, not for any
additional tools like PerlScript, PerlIS, PerlEz or PerlEx.

* Is there a better way to do this in perlscript? Is there another
  global variable I can just access? (similar to Err in VBScript).

You could use $Win32::OLE::LastError, which is the same as
Win32::OLE->LastError() as long as no subclassing of the module
is going on.  You can do

   *Err = \$Win32::OLE::LastError;

to use a $Err global in your code, or even better:

   sub Err () { $Win32::OLE->LastError }

Cheers,
-Jan



_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to