Rexx2Nrx.Rexx2RT.RexxMsg ( vs 4.00, January 2003)
The class RexxMsg implements a couple of useful routines for Terminal (Console) I/O. The major new features (as compared to pure Rexx/NetRexx) include:
- automatic logging of all terminal I/O to a LOG-File
- options to suppress console Output (option quiet)
- enhanced Input with user prompts and predefined answer lists assure simplified coding of user input sequences with data validation..
A LOG_File of all I/O messages is retained, so that the user might inspect the messages later. In addition, when option pause is in effect, output halts ate the end of the screen, so that the user might inspect the messages before continuing operation. The following methods are available. Also, when input is from a file, the respective lines and line-numbers are displayed in case of a warning or error.
For short reference, the best approach is to put RexxMsg to the USES list of your NetRexx program, e.g.:
Import Rexx2Nrx.Rexx2RT.RexxMsg
Class class-name[parameters] USES RexxMsg, ...
Terminal input methods:
method askfor(prompt=Rexx '') public static returns Rexx
displays the prompt string, and returns the answer. Note that the prompt string and the answer are recorded in the log-file as a single log-record (when the logging mechanism is requested).
Example: myfile=askfor(‚enter filename (or STOP)‘)
Also note, that a colon (:) is added to the prompt (unless the prompt string ends with a question mark(?) or a colon(:)..
method askfor(prompt=Rexx,answer_list=Rexx) public static returns Rexx
displays the prompt string, followed by the answer list (in parenthesis) and accepts the answer, but only if it matches an entry in the answer-list. Note that the answer list is compared case-blind, and abbreviated. When no match is found, the prompt is repeated until the answer is in the permitted answer-list. When the user did enter an abbreviation, the full answer from the answer list is returned, and the calling program needs not to bother with these special cases.:
the statement
yesorno=askfor(‚Do you want to re-use this file‘,‘Yes No‘)
will look like:
Do you want to re-use this file (Yes/No) : Y
Note that the returned value is ‚Yes‘ even when ‚Y‘ (or ‚y‘) has been entered by the user. Note also, that the possible answers are delimited by a slash(/) when the answer list is displayed.
If the given answer is not in the answer list, an error message is displayed and the user is asked again, until the given answer is in the answer list!
Informational, Error Message, and Warning routines:
The RexxFile package contains a couple of needful utility routines for sending messages to the user. A LOG-file of all messages is maintained in addition to saying the message,
Terminal Output methods:
method info(msg) public static
displays a message (like say, but with log-file). The number of informational messages are counted in n_info
method info2(msg) public static
displays a message with double underline (=). In addition, a blank line is displayed before and after the message.
method info1(msg) public static
displays a message with single underline (-). in addition, a blank line is displayed before the message. This routine may be used to display headers, or instance.
method warning(msg) public static
displays a warning message, including the last Current Line (line number and line content). The number of warning messages are counted in ‚n_warnings‘. When the Rexx2Nrx parsing routines (RexxParse) are used, the actual token pointer is displayed as well.
method error(msg) public static
like warning, but an ‚Error: msg‘ is displayed. The errors are counted in n_errors.
method abort(msg=Rexx '') public static
should be used for severe, terminating errors. Displays an ‚abort-message‘, closes all files, and exits the program with error 99.
method pause(msg=Rexx '') public static
displays the given message, and pauses afterwards, giving the user a chance to read the last bulk of messages on the screen.
special cases are:
pause('OFF') - turns pausing after m_screen-lines OFF.
pause('ON') - tunrs pausing after m_screen_lines ON.
If no msg is given, the message 'More ...' is displayed at the right lower corner, a behaviour simulating IBM CMS for compatibility.