invalidOptionSeen()

Checks if the command line options are misused.

Syntax

Getopt.invalidOptionSeen( )
  RETURNS BOOLEAN

Usage

This is a method for the Getopt type, that returns TRUE if the command line options are not specified correctly as defined by the GetoptOptions definition of the Getopt object.

The command line is considered as invalid in the following cases:
  • When an unknown option is used (not defined in the GetoptOptions array).
  • When a required option argument is missing (arg_type == getopt.REQUIRED).

The invalidOptionSeen() method can be used after calling the getopt() method processing command line options in a loop, to detect invalid options usage.

When an invalid command line option usage is detected, display the usage with the displayUsage() method and exit the program with an error status with EXIT PROGRAM 1.

Example

IMPORT FGL getopt

MAIN
    DEFINE g getopt.Getopt
    ...
    WHILE g.getopt() == getopt.SUCCESS
        ...
    END WHILE

    IF g.invalidOptionSeen() THEN
        CALL g.displayUsage()
        EXIT PROGRAM 1
    END IF

END MAIN