Command Line Argument Parsing 
Author Message
 Command Line Argument Parsing

Hi all,

How do you guys parse command line arguments?

For example, my application has the following arguments:

test c:\some directory\text.txt c:\output\test.txt TEXTFILE SomeDataBaseDSN

I use Microsoft.VisualBasic.Command() to retrieve the command line
arguments, but how do I parse the directories properly?  Directories can
have spaces which messes up SPLIT.

Any ideas?

Thanks.

--

Please delete "REMOVE" from the e-mail address when replying.
http://www.*-*-*.com/



Sun, 16 Oct 2005 03:58:49 GMT  
 Command Line Argument Parsing
Hi Lucas,

The first problem you need to solve is the identification of the parameters,
the simplest way is to add option like:

test -i c:\test files\inpit.txt -o c:\out files\output file

Then you can use the following to parse the command line:

Dim separators As String = " -"
Dim commands As String = Microsoft.VisualBasic.Command()
Dim args() As String = commands.Split(separators.ToCharArray)

This will result in the array args() that consist of the parameters.

Good luck,
Egbert


Quote:
> Hi all,

> How do you guys parse command line arguments?

> For example, my application has the following arguments:

> test c:\some directory\text.txt c:\output\test.txt TEXTFILE
SomeDataBaseDSN

> I use Microsoft.VisualBasic.Command() to retrieve the command line
> arguments, but how do I parse the directories properly?  Directories can
> have spaces which messes up SPLIT.

> Any ideas?

> Thanks.

> --

> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/



Sun, 16 Oct 2005 04:24:09 GMT  
 Command Line Argument Parsing
Dim passstring As String

For i = 0 To Environment.GetCommandLineArgs().Length - 1

Console.WriteLine(Environment.GetCommandLineArgs(i))

passstring = (Environment.GetCommandLineArgs(i))

Next i


Quote:
> Hi all,

> How do you guys parse command line arguments?

> For example, my application has the following arguments:

> test c:\some directory\text.txt c:\output\test.txt TEXTFILE
SomeDataBaseDSN

> I use Microsoft.VisualBasic.Command() to retrieve the command line
> arguments, but how do I parse the directories properly?  Directories can
> have spaces which messes up SPLIT.

> Any ideas?

> Thanks.

> --

> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/



Sun, 16 Oct 2005 04:06:31 GMT  
 Command Line Argument Parsing
Hello,


Quote:
> How do you guys parse command line arguments?

\\\
Public Module modMain
  Public Sub Main(ByVal astrCmdLineArgs() As String)
    Dim i As Integer
    For i = 0 To astrCmdLineArgs.Length - 1
      Console.WriteLine(astrCmdLineArgs(i))
    Next i
  End Sub
End Module
///

-- or --

\\\
Public Module modMain
  Public Sub Main()
    Dim i As Integer
    For i = 0 To Environment.GetCommandLineArgs().Length - 1
      Console.WriteLine(Environment.GetCommandLineArgs(i))
    Next i
  End Sub
End Module
///

Regards,
Herfried K. Wagner



Sun, 16 Oct 2005 05:40:58 GMT  
 Command Line Argument Parsing


Quote:
> Hi Lucas,

> The first problem you need to solve is the identification of the
> parameters, the simplest way is to add option like:

> test -i c:\test files\inpit.txt -o c:\out files\output file

I knew it was a simple way to fix this problem.  I added a / as a
delimiter.

Thank you.

--

Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/



Sun, 16 Oct 2005 07:55:44 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Interpreting/parsing a command line type of argument

2. Parsing Command line Arguments in VB Script

3. reading/parsing command line arguments AND return codes from vbs's

4. Command-Line arguments using Command()

5. WScript.Arguments won't parse double-quotes within arguments

6. Code to parse the command line

7. Command Line Parsing

8. Looking for robust command line parse algorithm

9. parsing command line

10. Help: Command line parsing

11. getopt / command line parsing

12. Help Parsing Command Line Parms

 

 
Powered by phpBB® Forum Software