On Oct 24, 2006, at 1:49 PM, Kem Tekinay wrote:
Before I reinvent the wheel, does anyone know of a good argument-
parsing
class for console apps?
Here's something I use that works quite well:
Decide on how you require the opts delimited (-, --, or other chars)
and use Split to create an array of args. Step through the args:
Dim args(-1) As String
Dim x As Integer
Args = Split(System.CommandLine, "--") // I used --
for x = 1 to UBound(args)
Select Case NthField(args(x), "=", 1) // Use the = as a delimiter IN
the args
Case "type"
Select Case NthField(args(x), "=" 2)
Case "log"
// do log stuff
Case "image"
// do image stuff
End Select
Case "List"
// handle list input
Case ...
End Select
Next
Any args that don't have have secondary parameters would simply be
the first side of the Nthfield in the first test. The second
parameter would allow for arguments to the options:
MyApp --type=log --List=/tmp/mylist --compress --
sendmail="[EMAIL PROTECTED]"
HTH,
TIm
--
Tim Jones [EMAIL PROTECTED]
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>