Sign in Join
FPDoc Onlineexperiment

SplitCommandLine function

In unit StrUtils

Split commandline in a series of separate arguments.

Declaration

pascal
function SplitCommandLine(S: RawByteString): TRawByteStringArray

Description

SplitCommandline parses S into words separated by whitespace, and returns a list of separate words (command-line arguments): When parsing it takes into account quoting with single (') or double quote (") characters: a word that contains whitespace can be enclosed in a quote character and will be considered a single word.

You can call this function with a UnicodeString or a RawByteString, the resulting array will have the same type of elements.

for example:

first "second argument" 'third argument'

Will result in an array of 3 elements

  • first
  • second argument
  • third argument

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.