Process Command Line Arguments

I have done a search for processing command line arguments and noticed that it seems no one has come up with a good one that works quotation marks, so I thought I would try my hand at rolling my own and think I have come up with a decent one:

Public Function GetArguments() As String()
  Var Results() as String
  
  var Temp as String = System.CommandLine.Replace(app.ExecutableFile.NativePath, "").Trim
  var TempList() as String = Temp.Split(" ")
  
  var Current as String
  for each Txt as String in TempList
    if txt.BeginsWith(Qt) then
      Current = Txt
    elseif txt.EndsWith(Qt) then
      Current = Current.Add(Txt, True)
      Results.Add(Current)
      Current = ""
    else
      Results.add(Txt.Trim)
    end if
  next Txt
  
  Return Results
End Function

NOTE: Qt is a global constant string defined as "

1 Like

Try @Jeremy_Cowgar 's OptionParser for advanced features.

1 Like