msnews
Tue Jul 20 10:16:19 CDT 2004
Thanks for your reply,
strArg1 = "LOCALHOST" ' default value if argument not given
WScript.Echo strArg1 ' will echo LOCALHOST
strArg1 = arrArgs(1) ' when get to this line i recive the same error, still
how do i check the user input to know if a value was supplied?
----------------------------------------------
"Torgeir Bakken (MVP)" <Torgeir.Bakken-spam@hydro.com> wrote in message
news:ueHO5ombEHA.3480@TK2MSFTNGP11.phx.gbl...
> msnews.microsoft.com wrote:
>
> > Hi,
> >
> > I have a command line script that accepts arguments. The problem I face
is I
> > fell to use the functions IsNull & IsEmpty in order to validate the
> > arguments. I receive the follwoing error: Microsoft VBScript runtime
error:
> > Subscript out of range.
> >
> > I do not wish to restrict the user to supply all 4 arguments by using
the
> > Count property but instead I need to know if a specific argument is
empty.
> Hi
>
> This is one way of doing it:
>
>
> Set arrArgs = WScript.Arguments
>
> On Error Resume Next
> strArg0 = "" ' default value if argument not given
> strArg0 = arrArgs(0)
> strArg1 = "" ' default value if argument not given
> strArg1 = arrArgs(1)
> strArg2 = "" ' default value if argument not given
> strArg2 = arrArgs(2)
> strArg3 = "" ' default value if argument not given
> strArg3 = arrArgs(3)
> On Error Goto 0
>
>
>
>
> --
> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
> Administration scripting examples and an ONLINE version of
> the 1328 page Scripting Guide:
>
http://www.microsoft.com/technet/scriptcenter/default.mspx