'--------------------------------------------------------------------------- ' ' GetArgs() - Parse the command line ' ' Chop up the command line, fill in the argument vector, return the ' argument count (similar to the Unix/C argc/argv handling) '--------------------------------------------------------------------------- Private Function GetArgs(argv() As String) As Integer Dim buf As String Dim i As Integer, j As Integer, l As Integer, n As Integer buf = Trim$(Command$) ' Get command line l = Len(buf) ' Length of command line If l = 0 Then ' If empty GetArgs = 0 ' Return argc = 0 Exit Function End If i = 1 ' Start at 1st character n = 0 ' Index in argvec Do While ((i < l) And (n < MAX_CMDARGS)) ' Safety stop here j = InStr(i, buf, " ") ' J -> next space If j = 0 Then Exit Do ' Exit loop on last arg argv(n) = Trim$(Mid$(buf, i, j - i)) ' Get this token, trim it i = j + 1 ' Skip that blank Do While Mid$(buf, i, 1) = " " ' Skip any additional whitespace i = i + 1 Loop n = n + 1 ' Bump array index Loop argv(n) = Trim$(Mid$(buf, i, (l - i + 1))) ' Get last arg GetArgs = n + 1 ' Return arg count End Function