[Overview][Types][Classes][Variables][Index] | Reference for unit 'CustApp' (#fcl)

# TCustomApplication.CheckOptions

Check whether all given options on the command-line are valid.

## Declaration

Source position: custapp.pp line 76

`public function TCustomApplication.CheckOptions(`
`const ShortOptions: string;`
`const Longopts: TStrings;`
`Opts: TStrings;`
`NonOpts: TStrings;`
`AllErrors: Boolean = False`
`):string; function TCustomApplication.CheckOptions(`
`const ShortOptions: string;`
`const Longopts: array of string;`
`Opts: TStrings;`
`NonOpts: TStrings;`
`AllErrors: Boolean = False`
`):string; function TCustomApplication.CheckOptions(`
`const ShortOptions: string;`
`const Longopts: TStrings;`
`AllErrors: Boolean = False`
`):string; function TCustomApplication.CheckOptions(`
`const ShortOptions: string;`
`const LongOpts: array of string;`
`AllErrors: Boolean = False`
`):string; function TCustomApplication.CheckOptions(`
`const ShortOptions: string;`
`const LongOpts: string;`
`AllErrors: Boolean = False`
`):string;`

## Arguments

`ShortOptions` |  | List of valid short options.
`Longopts` |  | List of valid long options.
`Opts` |  | Valid options passed to the program.
`NonOpts` |  | Non-option strings passed to the program.
`AllErrors` |  | Should all errors be returned, or just the first one?

## Function result

Empty string or error-message

## Arguments

`ShortOptions` |  | List of valid short options.
`Longopts` |  | List of valid long options.
`Opts` |  | Valid options passed to the program.
`NonOpts` |  | Non-option strings passed to the program.
`AllErrors` |  | Should all errors be returned, or just the first one?

## Arguments

`ShortOptions` |  | List of valid short options.
`Longopts` |  | List of valid long options.
`AllErrors` |  | Should all errors be returned, or just the first one?

## Arguments

`ShortOptions` |  | List of valid short options.
`LongOpts` |  | List of valid long options.
`AllErrors` |  | Should all errors be returned, or just the first one?

## Arguments

`ShortOptions` |  | List of valid short options.
`LongOpts` |  | List of valid long options.
`AllErrors` |  | Should all errors be returned, or just the first one?

## Description

CheckOptions scans the command-line and checks whether the options given are valid options. It also checks whether options that require a valued are indeed specified with a value.

The ShortOptions contains a string with valid short option characters. Each character in the string is a valid option character. If a character is followed by a colon (:), then a value must be specified. If it is followed by 2 colon characters (::) then the value is optional.

LongOpts is a list of strings (which can be specified as an array, a TStrings instance or a string with whitespace-separated values) of valid long options.

When the function returns, if Opts is non-Nil, the Opts stringlist is filled with the passed valid options. If NonOpts is non-nil, it is filled with any non-option strings that were passed on the command-line.

The function returns an empty string if all specified options were valid options, and whether options requiring a value have a value. If an error was found during the check, the return value is a string describing the error.

Options are identified as command-line parameters which start with OptionChar (by default the dash ('-') character).

if AllErrors is True then all errors are returned, separated by a sLineBreak character.

## Errors

If an error was found during the check, the return value is a string describing the error(s).

## See also

FindOptionIndex |  | Return the index of an option.
GetOptionValue |  | Return the value of a command-line option.
HasOption |  | Check whether an option was specified.
CaseSensitiveOptions |  | Are options interpreted case sensitive or not
OptionChar |  | Command-line switch character