Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]

Arc de Triomphe clipart (2486 bytes)The INPUT class library

Written by Kane Marshall (kanemars@yahoo.co.uk).

kane.zip (7639 bytes)

This class library provides safe command line input routines. It has been implemented in TowerEiffel 2.0, and can easily be implemented in other versions of Eiffel. This class library is released to the public domain.

Description of class INPUT

The routines of class INPUT that get information from the command line ensure that the text entered is in the correct format, otherwise a `follow_up_prompt' will repeatedly be displayed until an acceptable string is entered. The `follow_up_prompt' can be set with the procedure `set_follow_up_prompt'. A default `follow_up_prompt' setting will always be used.

Procedure `get_non_empty_string' ensures a string of at least one non whitespace character is entered. An example of its use is:

     in: INPUT
     !! in
     in.put_string ("Enter your name: ")

Procedure `get_formatted_string' ensures a string satisfies the rules provided by a FORMAT_TEST object (described next).

Description of class FORMAT_TEST

FORMAT_TEST is a supporting class of INPUT of which the deferred feature `is_correct_format' ensures that an entered string is of the correct format. Each descendant of FORMAT_TEST has to define a `default_follow_up_prompt'.

One such descendant of FORMAT_TEST is OPTIONS, which ensures the string entered is a printable representation (`out') of one of a selection of specified objects. An example of its use is:

     in: INPUT
     rules: FORMAT_TEST
     !! in
     !OPTIONS! rules.make (<<0, 1, "more", 'm'>>)
     in.put_string ("How many siblings do you have (0, 1 or more)?")
     in.get_formatted_string (rules)

The example class DDMMYYY_TEST ensures that a string entered is in dd/mm/yyyy format.

The deferred generic class RANGE ensures that the string entered is of a correct format and also within a specified range of two values `lower' and `upper'. Example descendants of this class are INTEGER_RANGE and DATE_RANGE, whose names are self explanatory.

Description of class IO_TESTER

IO_TESTER is a root class which tests the features of the INPUT class library. Example output from this running system is stored in file `out.exp'.


Kane Marshall
Vascular Informatics Group
Vascular Surgical Unit
B Floor Brotherton Wing
Leeds General Infirmary
Great George Street
West Yorkshire
United Kingdom

Home Page ] [ Eiffel Archive ] [ Eiffel Classes and Clusters ]