ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> pdk-beta
pdk-beta
Re: [PDK-Beta] VBSPerl-Beta1
by Eric Promislow other posts by this author
Jun 15 2004 1:11PM messages near this date
view in the new Beta List Site
Re: [PDK-Beta] VBSPerl-Beta1 | Re: [PDK-Beta] VBSPerl-Beta1
Hi, Jenda,

Thanks for the note.

You're right about the code we generate on Mid() -- we can
map directly to substr().  And you need to decrement the
index: Perl is 0-based, Basic 1-based (sort of).

As for the CreateObject error, the converter assumes that
the input is correct VB.  Objects must be assigned with
a 'set' statement.  So

set x = createObject("Scripting.Dictionary")

is recognized, and it's a current bug to map these objects to
Perl's hashes.  Good comment on the case -- we do preserve
case of most names, as case matters in Perl, but not for
the names of built-ins.

Thanks for the comment on error messages.  I'll open another
bug on it.

- Eric


On Tue, Jun 15, 2004 at 03:06:35PM +0200, Jenda Krynicky wrote:
>  From: "Jan Dubois" <jand@[...].com>
>  > We have uploaded the next PDK Beta feature to the FTP server: VBSPerl,
>  > a VBScript (and VBA) to Perl converter.
>  > ...
>  
>  Thanks. I did not run a lot of tests yet, but it seems to work so 
>  far.
>  
>  I expected a little better handling of the builtin string functions 
>  though:
>  
>  x = "hello"
>  x = Mid( x, 2, 3)
>  
>   ====>
>  
>  #!perl
>  
>  use Win32;
>  use Win32::OLE qw(in with);
>  use Win32::OLE::Variant;
>  use Win32::OLE::Const "Visual Basic For Applications";
>  
>  $x = 'hello';
>  $x = VBS::Mid($x, 2, 3);
>  
>  package VBS;
>  use strict;
>  sub Mid {
>    my($substr, $start, $len) = @_;
>    $start--;
>    return defined $len ? substr($substr, $start, $len) :
>                          substr($substr, $start);
>  }
>  
>  
>  I expected something like
>  
>  x = Mid( x, 2, 3)
>  	=>
>  $x = substr( $x, 2+1, 3);
>  
>  and
>  
>  x = Mid( x, 2)
>  	=>
>  $x = substr( $x, 2+1);
>  
>  But I guess there is just a list of these builtins and their Perlish 
>  implementations inside vbsperl and the calls are just translated 
>  syntacticaly, right.
>  
>  There is no chance the vbsperl sources will be released so that we 
>  could tweak them and add these special cases right?
>  
>  I also tried to convert a snippet of code using Scripting.Dictionary 
>  just to see whether it will be converted to using Perl hashes. Though 
>  I did not expect that to happen.
>  It would be cool if this was possible.
>  
>  
>  Also I think the errors in translations should be printed a little 
>  differently:
>  
>  x = CreateObject("Scripting.Dictionary")
>  	=>
>  $x =
>  #### Error: Can't resolve builtin createobject
>  ;
>  
>  should IMHO be something like
>  
>  $x = do { BEGIN { die "VBSPerl Convertor Error: Can't resolve builtin 
>  createobject" } };
>  
>  That way the user gets a nice compile-time error message if he/she 
>  tries to run the converted code.
>  
>  (And it seems you do not print the name of the unknown builtin in the 
>  original case, but lowercased.)
>  
>  Jenda
>  Jenda
>  ===== Jenda@[...].cz === http://Jenda.Krynicky.cz =====
>  When it comes to wine, women and song, wizards are allowed 
>  to get drunk and croon as much as they like.
>  	-- Terry Pratchett in Sourcery
>  
>  _______________________________________________
>  PDK-Beta@[...].com
>  http://listserv.ActiveState.com/mailman/listinfo/pdk-beta
_______________________________________________
PDK-Beta@[...].com
http://listserv.ActiveState.com/mailman/listinfo/pdk-beta
Thread:
Eric Promislow
Jenda Krynicky

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved