ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  VBScript or Perl?
Subject:   VBScript disadvantages...
Date:   2004-11-01 12:59:16
From:   regisdesrosiers
Corrections:


VBScript has command line parsing support as long as you put your code in a WSF file. You can then access arguments with WScript.Arguments.


As for the GUI, you can get a very flexible GUI system by putting your code in a HTA.


Your wordy VBScript example could have been written clearly by using a function that return a fully defined RegEx object somewhere else in your code:



Function MyRegEx(Pattern)
Set MyRegEx = New RegExp
MyRegEx.Pattern = Pattern
MyRegEx.IgnoreCase = True
MyRegEx.Global = True
End Function


Then you code become less awkward than Perl.


if MyRegEx("www").Test("www.rallencorp.com") then
WScript.Echo "Matched"
else
WScript.Echo "Did not match"
end if


You cannot directly execute code from the command line but it is really not complicated to do a script that will using the Execute method.


As for the future of VBS, the transition from VBS to VB.NET is really smooth if you do not insist on compiling strict. Much smoother than from VB6 in fact. When you have added parenthesis when calling subs you are pretty much done.