Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Converting Visual Basic Code to PERL

by harish (Novice)
on May 16, 2003 at 12:40 UTC ( #258625=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks,

Iam trying to convert a small program from VB to Perl. I am having problem with this line.

In VB, the line is :
oReport.Export (False) ## and this works fine.
In Perl, Iam have tried the following...and other combinations..
$oReport->Export 0 ; $oReport->Export(0) ;
But neither works.. Any other ideas..

Thanks
Harish

edited: Fri May 16 13:37:43 2003 by jeffa - code tags - formatting

Replies are listed 'Best First'.
Re: Converting Visual Basic Code to PERL
by Jenda (Abbot) on May 16, 2003 at 12:55 UTC

    Try

    use Win32::OLE::Variant; $oReport->Export(Variant(VT_BOOL, 0));

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature

      AweSome. This works.
      Thanks a bunch.
      Harish
Re: Converting Visual Basic Code to PERL
by LAI (Hermit) on May 16, 2003 at 12:48 UTC

    harish, I have worked to convert and adapt a lot of programs from one language to another, and the best advice I can give you is to forget about doing a translation. Different languages often "think" in different ways, and Perl vs. VB is a perfect example of this. VB is by necessity full of hacks, it has screwed up structures and so forth.

    Rather than trying to do a line-by-line conversion to Perl, start from scratch. In the long run, you will thank yourself (especially for small programs like this one).

    LAI

    __END__

      I wholeheartedly agree with LAI.

      When translating spoken language, do you do a direct translation? No. It's a rare occasion when one can run down a sentence with a dual-language dictionary and get a coherent sentence.

      Take for example English and Russian. Ignoring the Cyrillic and Latin character differences, both have some similar sounding words, but the grammar and syntax is completely different. Two languages that are more closely related are English and German (or French and Spanish). Same problem there. You can't simply translate, you have to interpret.

      First, figure out what you want to do in Perl. Is there any reason Perl is better suited than the already complete VB code? Then, start from scratch in Perl. Don't even look back at your VB. Construct something completely new (and better (always improve your code)) that accomplishes the same task.

      John J Reiser
      newrisedesigns.com

Re: Converting Visual Basic Code to PERL
by Tanalis (Curate) on May 16, 2003 at 12:45 UTC
    Can you provide some error messages, and maybe a larger extract of code to work from? It's very difficult (impossible) to even start to try and understand what's going on from the one line of code you've posted.

    Thanks,
    -- Foxcub
    #include www.liquidfusion.org.uk

      Here's the Full Code. Iam trying to connect to a existing Crystal Report and save it as a excel file.
      use Win32::ODBC; use Win32::OLE; $ex = Win32::OLE->new('CrystalRuntime.Application', sub {$_[0]->Quit;} +) or die "Oops, cannot start Crystal"; $oReport = $ex->OpenReport ('C:\CrystalParameters\Myreportone.rpt', 1) + ; $oReport->{'EnableParameterPrompting'} = 0 ; $oexportoptions = $oReport->{'ExportOptions'} ; #######set the Export Options to Export it to Excel file ############# +##### $oexportoptions->{'FormatType'} = 36 ; $oexportoptions->{'DestinationType'} = 1 ; $oexportoptions->{'DiskFileName'} = 'c:\mytestreportone.xls' ; ####################################################### $oReport->Export(0);

      Edit: Added <code> tags. larsen

        Perhaps you should check with your documentation on whether this is exported as a COM method. I use LotusScript occasionally and some functions are designated as COM-only and others are inaccessible from COM (there's always a work-around though)

Re: Converting Visual Basic Code to PERL
by Biker (Priest) on May 16, 2003 at 12:53 UTC

    Remember that in Visual Basic, False is defined as -1. (Minus one.)

    Update: Absolutely right. As a result, I think that my node should be deleted, since it provides incorrect information. (Doh)

    My only defense is that it was so long ago I wrote any Visual Basic. I should of course have verified my statement before writing the node.


    Everything went worng, just as foreseen.

      No, that's True you just described. True is any non-zero integer though casting True to Integer results in -1. False is zero.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://258625]
Approved by Tanalis
Front-paged by demerphq
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2022-06-25 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (81 votes). Check out past polls.

    Notices?