forgedascendant has asked for the wisdom of the Perl Monks concerning the following question:

Good afternoon monks,

I come here before you seeking your help. The issue I have is that I can not get the getValue method working (while various other methodes and properties work fine). I have searched and played on the Mathcad end (to the extent of calling the company and requesting their help) only to find that the problem is not on that end. The VBA code they supplied me as proof that the methode works executes fine on their end. SO I went to my perl code and examined that to find nothing there either. There is only one place left to look and that is the bridge (Win32::OLE module). It has been suggested to me that there could be an issue with threads. To evaluate this I will need the help of a few brave monks being that I have no clue as to what a thread even is.

This is the Perl script:

#!/usr/ym/util/perl use Win32::OLE; #Perl "C:/documents and settings/aaron.verellen/desktop/trial2.pl" Win32::OLE->Option(Warn => 2); #use existing instance if mathcad is already running eval {$MC = Win32::OLE->GetActiveObject('Mathcad.Application')}; die "Mathcad not installed" if $@; unless (defined $MC) { $MC = Win32::OLE->new('Mathcad.Application', sub{$_[0]->Quit;}) or die "Unable to start Mathcad"; } #Open specific worksheet my $filePath = 'C:\Documents and Settings\aaron.verellen\Desktop\testM +12.xmcd'; my $WS = $MC->Worksheets; my $S = $WS->Open($filePath); #Set values on the worksheet $S->setValue('x',50); $S->setValue('y',60); $S->setValue('z',70); $S->Recalculate; my $answer1 = $S->getValue('output1'); my $answer2 = $S->getValue('output2'); print "($answer1,$answer2)\n";
Mathcad program does the following:

output1=x+y+z
output2=(x+y+z)/3

When I execute the perl script I get:

C:\>Perl "C:/documents and settings/aaron.verellen/desktop/trial2.pl" Win32::OLE(0.1709) error 0xc00000fd in METHOD/PROPERTYGET "getValue" at C:/documents and settings/aaron.verellen /desktop/trial2.pl line 30

So, is there any among you brave enough to answer this call?

Replies are listed 'Best First'.
Re: Win32::OLE Help required
by Corion (Patriarch) on May 06, 2009 at 17:43 UTC

    You could at least have the decency and link to WIN32::OLE bridging to MATHCAD or Re^4: WIN32::OLE bridging to MATHCAD, of which your post is basically a duplicate. I guess without Mathcad at our disposal, the problem cannot be replicated by us. If the Mathcad people don't know of a problem then it is likely a difference in how Mathcad does OLE and everybody else (that is, Excel) does OLE.

Re: Win32::OLE Help required
by ig (Vicar) on May 07, 2009 at 01:42 UTC

    I have seen cases where an OLE get method requires a variant to be passed and it sets the value of the variant. Such details may be handled "magically" by VB and you may have to be explicit with perl. I have no idea about mathcad or what the underlying (i.e. beneath the hood of VB) interface looks like. Nor do I have mathcad to test with. You might try investigating with a com object explorer to see what you can find about the getValue method.