Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Converting VBScript to PerlScipt

by Nesh (Beadle)
on Mar 16, 2005 at 01:48 UTC ( [id://439836]=perlquestion: print w/replies, xml ) Need Help??

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

Hello People I am trying to convert a WSF file using VBScript to a WSF File using PerlScript. I am stuck at the following:
If WScript.Arguments.Named.Exists("CycleDate") Then cycleDate = WScript.Arguments.Named("CycleDate") End If
I have no idea what this does as I don't know VBScript. Can you please help me with this so that I can make the required changes in perl. Thanks

20050317 Edit by castaway: Changed title from 'Windows Script problem'

Replies are listed 'Best First'.
Re: Converting VBScript to PerlScipt
by maa (Pilgrim) on Mar 16, 2005 at 08:14 UTC

    VBScript has two types of arguments... Named and Anonymous and they are provided as follows:

    C:> cscript.exe /nologo script.vbs /CycleDate:01-12-2005 /Test:2 Arg1 +Arg2 Arg3

    This results in three Collection Objects Arguments(), Arguments.Named() and Arguments.UnNamed()

    These will have elements

    'VBScript, not Perl Arguments.Named("CycleDate") 'value="1-12-2005" Arguments.Named("Test") 'value="2"

    There should be three elements of Arguments.UnNamed() with values "Arg1", "Arg2" and "Arg3".

    Documented at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wslrfnamedproperty.asp

    If you're converting you might use Getopt::Long - then you'd have GetOptions( "CycleDate"=>\$cycledate ...) or warn...

    HTH -- Mark

Re: Converting VBScript to PerlScipt
by Tanktalus (Canon) on Mar 16, 2005 at 03:00 UTC

    When I am converting code from one language to another (which I thankfully don't need to do now - that was a student job I had back in 1993 - converting ForTran to C, what a mistake!), it's more important to know what it is doing (conceptually) than knowing how to convert.

    What I mean is that I tried to convert ForTran to C. I would write C code that did exactly the same as what the ForTran code did. I did that for exactly one program. The rest of the conversions were done by figuring out what the input was, what the output was, and then rewriting (from scratch) everything in between. When I left that job, the only program that wasn't working was the first one. Everything else was working fine when I graduated from university (1997) and went back to thank my former manager for what I learned there.

    The only exception was when I went back to look at the original code was when I couldn't figure out a mathematical formula - math is picky like that ;-)

    Short version: what is a WSF file? What is your input, what is your output?

Re: Converting VBScript to PerlScipt
by Anonymous Monk on Mar 16, 2005 at 05:04 UTC
Re: Converting VBScript to PerlScipt
by jbrugger (Parson) on Mar 16, 2005 at 05:16 UTC
    WScript.Arguments.Named is just some sort of hash, as far as i know. Correct?
    Here nice example of how to work with it.
    then in perl it would be:
    If ($argument->{CycleDate}) { $cycleDate = $argument->{CycleDate} }
Re: Converting VBScript to PerlScipt
by japhy (Canon) on Mar 16, 2005 at 04:47 UTC
    I'm guessing that this is looking to see if WScript has a named argument to it (kinda like prog -CycleDate=xyz) and if so, storing its value in some variable. But I don't know VB.
    _____________________________________________________
    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-04-24 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found