Thursday, July 30, 2009

Ambigous Win32:OLE::LastError() Message

Running this code snippet:
use Win32::OLE;
$lrEngine = Win32::OLE->new('wlrun.LrEngine');
$lrScenario = $lrEngine->Scenario();
$rc = $lrScenario->new(0, 1);
# do not save previous
# regular vusers based scenario

$scriptLocation = 'PATH\TO\SCRIPTNAME\SCRIPTNAME.usr';
$scriptName = 'SCRIPTNAME';
$lrScenario->Scripts->Add($scriptLocation, $scriptName);
print "Win32::OLE::LastError: ".Win32::OLE::LastError()."\n";
Yields:
Win32::OLE::LastError: Win32::OLE(0.1709) error 0x80020005: "Type mismatch"
in METHOD/PROPERTYGET "Add" argument 2
Yes, the code passes string, even changing the code to force COM BSTR usage still generates the same error message
use Win32::OLE::Variant;
$scriptName = Variant(VT_BSTR, 'SCRIPTNAME');
What gives? The code definitely follows the documentation to the dot
Function Add(Path As String, Name As String) As Long
Add Script to Scenario
The answer: Variants by reference, changing the code, to reflect the snippet below, fixes the problem.
use Win32::OLE::Variant;
$scriptName = Variant(VT_BSTR|VT_BYREF, 'SCRIPTNAME');

Wednesday, July 29, 2009

Submitted 1st Perl Bug To ActiveState

http://bugs.activestate.com/show_bug.cgi?id=83895

--Note: I see, basically reverse doesn't sort the list in reverse order, but it will reverse the list.

Reverse Function Is Not Working Properly

Dan caught it, not me
use strict;
my $DATA;
{
local $/ = undef;
my $DATA_text = ;
eval "$DATA_text";
die $@ if $@;
}
print "# incorrect reverse sort using reverse function\n";
foreach my $date (reverse keys %{$DATA}) {
print "$date\n";
}
print "\n";
print "# correct reverse sort\n";
foreach my $date (sort {$b cmp $a} keys %{$DATA}) {
print "$date\n";
}

__DATA__
$DATA = {
'2009/07/19' => {
files => 1,
},
'2009/07/12' => {
files => 1,
},
'2009/07/05' => {
files => 1,
},
'2009/06/28' => {
files => 1,
},
'2009/06/21' => {
files => 1,
},
};

It prints:
>perl reverse_problem.pl
# incorrect reverse sort using reverse function
2009/07/12
2009/07/05
2009/07/19
2009/06/28
2009/06/21

# correct reverse sort
2009/07/19
2009/07/12
2009/07/05
2009/06/28
2009/06/21

>perl -v

This is perl, v5.8.8 built for MSWin32-x86-multi-thread
(with 18 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 822 [280952] provided by ActiveState http://www.ActiveState.com
Built Jul 31 2007 19:34:48

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

--Apparently I can reproduced this using ActiveState v5.10.0 build 1001 [283495]