![]() |
Section 8.10.3.1: |
![]() |
The type definitions in this class specification fall into two groups :-
This class provides the facility to handle arbitrary program arguments in unix-style format. Program options may be made available either as the traditional Unix-style argument 'pack' or as a single string (provided, for example under DOS) or as the contents of some named file or some combination of these.
However the arguments to a program may be passed to it, they should conform to the concrete syntax defined in this sub-section. It should be noted that since arguments come from the program run-time environment their encoding and repertoire are necessarily those of the default culture.
NOTE | 1. All symbols are arbitrary bit-sequences determined from the default program argument mapping parameter file when the argument class is first created. |
2. There may be an arbitrary number of alternative quote symbols, the only restriction being that the encoding which is detected at the beginning of a quoted string must be the same as used at the end - and must not, of course, appear anywhere within the bit-stream of the string value itself. | |
3. Numeric values are presumed to begin with an encoding which is not a quote symbol, white space or option delimiter and is also not permitted as the first encoding in an identifier. Otherwise there are no restrictions on the encodings. |
After creation of an object any number of program parameters may be specifed in terms of their name and the function which is to be associated with it which is to be called when the name is recognised during argument reading.
Argument handlers must be closures of type ROUT{$OPTION}. As defined in this specification, there are options - CARD, FIELD, BOOL, INT, RAT, CPX, MONEY and STR. The facility for using a handler which receives an unquoted string is intended to permit handlers to take enumeration names as string value.
The following reader routines should be void until after arguments have been read -
Since this is a creation routine, the pre-condition is vacuously true.
Since this is a creation routine, the post-condition also is vacuously true.
This creation routine sets up a void program name and an empty list of arguments for a new object in the given culture and returns the object created.
This creation routine also produces an initially empty object, but uses the default encoding and repertoire.
create | : SAME |
Since this is a creation routine, the pre-condition is vacuously true.
Since this is a creation routine, the post-condition also is vacuously true.
This creation routine sets up a void program name and an empty list of arguments using the default culture encoding and repertoire.
This routine provides the facility to associate handlers with program options - which is to be done before reading the options using one or more of the read variants following.
add_option | ( |
name : STR, | |
func : ROUT{$OPTION}, | |
has_val : BOOL | |
) |
The addition of a handler always happens successfully by definition, thus the post-condition is inevitably true.
This routine adds a new option name with an associated handler to the object. Note, however, the pre-condition.
Should it be necessary to delete one or more options this routine provides the facility to do so.
delete_option | ( |
name : STR | |
) |
Since the contents of the string argument is arbitrary, the pre-condition is true.
If the string argument was the name of an option then it has been deleted. If the string argument was not the name of an option then the resulting state is as if it had been deleted. The post-condition is therefore true.
This routine deletes an option with the given name. It shall not be an error if the name did not exist.
This first argument reading feature looks to find arguments in a file with the given access path.
Should false be returned then the standard error channel has had some appropriate error message sent to it.
This routine reads the program options and arguments from the file indicated, returning true if this has been done successfully, otherwise false.
This routine offers the facility to read arguments from an already open text file.
Should false be returned then the standard error channel has had some appropriate error message sent to it.
This routine reads the file provided for options and arguments, returning true if and only if there have been no reported errors.
This third variant if argument reading is provided for the case where arguments have been put into an arbitrary text string.
Should false be returned then the standard error channel has had some appropriate error message sent to it.
This routine treats the given string as a list of options and arguments, reading them and returning true if and only if successful.
This final version handles command line arguments presented in the unix-style. It is important to note that this variant is the only one which can set the program name!
Should false be returned then the standard error channel has had some appropriate error message sent to it.
This routine handles the command line option/argument string case - the first item in the array being taken as the program name. True is only returned if and only if there have been no reported errors.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Input/Output Index |
Comments or enquiries should be made to
Keith
Hopper. Page last modified: Tuesday, 21 November 2000. |
![]() |