J3/98-135 Page 1 of 2 To: X3J3 From: JOR Subject: Command line arguments, specs,syntax,edits Date: Feb. 18, 1998 JOR has discussed this issue at length, and now wishes to propose the following specification, syntax, and edits. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Specification and Syntax: The PROGRAM statement may include the following arguments, as shown. The type of argument is what determines what is stored into it by the processor, not the actual name of the dummy argument. PROGRAM jerry (argument_text, argument_length, command_line) CHARACTER (LEN=*) :: command_line CHARACTER (LEN=*), DIMENSION (0:) :: argument_text INTEGER, DIMENSION (0:) :: argument_length The dummy arguments above, if specified, will have the following values: command_line -- the text of the command_line, in a processor dependent form argument_text -- the "parsed" command line. Parsing (delimiters etc.) is processor dependent argument_text(0) is the command name (if available) which invoked the current program argument_text(1) is the first argument on the command line . . . argument_text(size(argument_text)-1) is the last argument from the command line argument_length -- the effective lengths of the parsed arguments in "argument_text", used to trim insignificant blanks from the end of argument in "argument_text" (only needed if there might be significant trailing blanks, otherwise TRIM seems preferable). The "command_line" and "argument_text" arguments shall be of type default character and assumed length. The "argument_text" and "argument_length" arguments must be assumed shape. The "argument_length" argument must be of type default integer. An element of "argument_text" and the "command_line" argument will always be at least of length 1. When argument_text or argument_length is present on the PROGRAM statement, the lower bound shall be present in the declaration for that variable, and shall be zero. A length of zero (or all blanks) for an argument indicates no argument was present (in this position). argument_length(0) may be zero if the processor does not support the concept of, or cannot obtain a command name. The argument_text and argument_length arrays will always have at least one element (element (0)). J3/98-135 page 2 of 2 Edits: Section 11.1, R1102 [195:14], change "is PROGRAM program-name" to "is PROGRAM program-name [( program-arg-list )] R11xx program-arg is program-arg-name " Add a new section 11.1.1 [195:37+] and renumber the sections 11.1.1 - 11.1.3. "11.1.1 Main program arguments The PROGRAM statement may include the arguments described in this section. These variables, if present, are initialized by the processor as described below. The meaning and interpretation of the terms "command line", "command line argument", "delimiter", and "command name" are processor dependent. The actual name of each main program argument is not significant. The type of each argument shall be one those described in this section, and only one variable of each type shall appear in a PROGRAM statement. Program statement argument types and values: CHARACTER (LEN=*) :: command_line The "command_line" argument contains the processor dependent representation of the command line which invoked the program. The "command_line" argument shall be assumed length, and of type default character. LEN(command_line) will always be at least one. Note: Various user interfaces, including text and graphical user interfaces, may process the command line. Note: A program's command line includes information which is associated with the program at startup. This information includes, but is not limited to, character strings included with the program's startup command. CHARACTER (LEN=*), DIMENSION (0:) :: argument_text The "argument_text" array argument contains the text of the command line. "argument_text(0)" contains the command name from the command line. "argument_text(i)" contains the i'th argument after the command name. "argument_text(size(argument_text)-1)" contains the last argument from the command line. The "argument_text" argument shall be assumed length, assumed shape with an explicit lower bound of zero, and of type default character. LEN(argument_text(0)) will always be at least one. SIZE(argument_text) will be at least one. An element of "argument_text" will always be at least of length one. INTEGER, DIMENSION (0:) :: argument_length The "argument_length" array argument contains the length of the significant character string in each corresponding element in the "argument_text" array. The characters in a particular element of "argument_text" beyond the "argument_length(i)" position will be blanks. The "argument_length" argument shall be assumed shape with an explicit lower bound of zero, and of type default integer. SIZE(argument_length) will be equal to SIZE(argument_text). Note: A value of zero for an element of argument_length indicates the argument was not present, or could not be obtained by the processor. A value of zero for argument_length(0) indicates the processor did not provide a command name.