System.SysUtils.FindCmdLineSwitch
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.
Switchis a command-line parameter to search for.Charsis the set of characters that distinguish switches from other parameters. IfSwitchis omitted, it defaults to '-' on Unix based systems, and to '/' and '-' on Windows based systems.IgnoreCasedetermines 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.Valuereturns the value associated with the specified switch.SwitchTypesdetermines how parameter values are parsed:
Constant Value clstValueNextParam -p ValueclstValueAppended -p Valueor -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.)