System.SysUtils.FindCmdLineSwitch

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function FindCmdLineSwitch(const Switch: string; const Chars: TSysCharSet; IgnoreCase: Boolean): Boolean;
function FindCmdLineSwitch(const Switch: string): Boolean;
function FindCmdLineSwitch(const Switch: string; IgnoreCase: Boolean): Boolean;
function FindCmdLineSwitch(const Switch: string; var Value: string; IgnoreCase: Boolean = True; const SwitchTypes: TCmdLineSwitchTypes = [clstValueNextParam, clstValueAppended]): Boolean; overload;

C++

extern DELPHI_PACKAGE bool __fastcall FindCmdLineSwitch(const System::UnicodeString Switch, const TSysCharSet &Chars, bool IgnoreCase)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Determines whether a string was passed as a command-line argument to the application.

FindCmdLineSwitch determines whether a string represents a command-line switch, based on the first character of the string.

  • Switch is a command-line parameter to search for.
  • Chars is the set of characters that distinguish switches from other parameters. If Switch is omitted, it defaults to '-' on Unix based systems, and to '/' and '-' on Windows based systems.
  • IgnoreCase determines whether case-insensitive character matching is used. The default is True. This function can also be used to retrieve parameter values in addition to finding command-line switches, for that overload.
  • Value returns the value associated with the specified switch.
  • SwitchTypes determines how parameter values are parsed:
Constant Value
clstValueNextParam -p Value
clstValueAppended -p Value or -p:Value

The clstValueNextParam parameter specifies that values are separated from the switch by a space character. The clstValueAppended parameter specifies that the values are appended immediately, following the switch (no space) or after a colon. SwitchTypes is a set type parameter and the default is to allow values of both parameter types to be returned--[clstValueNextParam, clstValueAppended]. Any single switch type may be specified as well. An empty SwitchType parameter, [], will result in no values being returned. Pass the SwitchTypes parameter to exclude any of these switch types (Switch may be 1 or more characters in length.)

See Also