| Building a Console Application in VB for the Alibre Design API - Reading the Command Line Arguments |
|
|
Page 8 of 14 Reading the Command Line ArgumentsNow it's time to see if any of the command line arguments we specified above were present when the program was run. We do this by systematically looking at each of the arguments that were passed in, and comparing them to the arguments that our program cares about -- the ones we defined above. The block of code between the "For Each" line and the "Next" line will be run once for each argument on the command line. Each time it's run, we'll be able to use the variable "s" to look at the command line argument we're currently examining. In all cases, we're converting the command line argument to lower case, then seeing if it starts with one of the flags we defined in lines 11-13. If we get a match, the computer will run the code between the appropriate "If" and "End If" lines. In the first case, we're essentially removing the flag from the argument and storing the remainder of the string into the variable "outPath". This leaves us with only the path and filename that was included after the flag (e.g. "D:\MyOutput.txt"). In the last two cases, we're simple setting the boolean values defined in lines 17-18 to true if the command link flag was found. ' Read and parse the command line arguments
For Each s As String In My.Application.CommandLineArgs
If s.ToLower.StartsWith(outPathFlag) Then
outPath = s.Remove(0, outPathFlag.Length)
End If
If s.ToLower.StartsWith(configurationFlag) Then
includeConfigurations = True
End If
If s.ToLower.StartsWith(countFlag) Then
includeCount = True
End If
' More here if necessary...
Next
|
|
| Last Updated ( Monday, 28 January 2008 16:22 ) |
