NAME

baseIO.pm -- common input/output and simple tracing object.


VERSION

Version 1.00

4/20/2002


SYNOPSIS

 use EWS::baseIO;

 $baseIO = new EWS::baseIO(-debug => 0, 
                           -type  => 0);

 $baseIO->DisplayLine("this is a message");

 $baseIO->timestamp(1);
 $baseIO->DisplayLine("this message has a timestamp in front of it.");

 undef $baseIO;

DESCRIPTION

baseIO is a common input/output and simple tracing class. It provides an object-oriented, redirectable access to console input and output, allows standard redirection, and provides a mechanism to allow output to be sent to the current console, a log file, or both.

EWS::baseIO is an object-oriented basic input/output class. It provides redirectable access to console input and output, allows standard redirection, and provides a mechanism to allow output to be sent to the current console, a log file, or both.

EWS::baseIO was designed to be used as either a stand-alone object class, or as a base-class for other objects (such as EWS::htmlout). It supports full inheritence and all public methods and attributes were written to provide a straight-forward interface which may be safely overridden without harmful side effects.

PUBLIC METHODS

new

$baseIO = new EWS::baseIO(%parameters);

    Enter:
      %parameters = parameter hash (see below).
    Exit:
      returns a blessed reference to a new baseIO object.

    parameters are of the form:

      -arg => value

    acceptable values are:
      -debug      => 1 = debug messages
      -htmlformat => 1 = html format, else console format
      -timestamp  => 1 = timestamp display line messages
      -type       => 0 = console output (default)
                     1 = output to file only
                     2 = output to console and file (log messages)
      -end        => string to check for in input stream to end program
                        (default = 'exit')
      -file       => name of file for output (type = 1 or 2).
                        (default = /dev/null)

    Note:
      if -type > 0, and -file == undef, /dev/null is used as the output file.

acceptMessage

Accept input message.

    Enter:
      $programEnd = word or phrase to enter to end program.
    Exit:
      $inputBuffer = chomp-ed input buffer
      undef if user enters $programEnd.

Display

Output $message

    Enter:
      $message = message to output.
    Exit:
      none.

DisplayAndAccept

Display a message and wait for input.

    Enter:
      $displayMessage = message to display
      $programEnd = word of phrase to enter to end program.
    Exit:
      $inputBuffer = chomp-ed input buffer
      undef if user enters $programEnd.

DisplayAndPause

Display message then wait for enter to be pressed.

    Enter:
      $Message = message to display
    Exit:
      none.

DisplayDateString

Returns a formated string consisting of the current date and time.

    Enter:
      none.
    Exit:
      returns current date and time in the following
      format:

        hh:mm MM/DD/YYYY

DisplayLine

Display the contents of $message followed by newline. If $timestamp is set, first output a string representing the current time.

    Enter:
      $Message = message to output
    Exit:
      none.

DisplayLineAndAccept

Display a message followed by newline, and wait for input.

    Enter:
      $displayMessage = message to display
      $programEnd = word of phrase to enter to end program.
    Exit:
      $inputBuffer = chomp-ed input buffer
      undef if user enters $programEnd.

DisplayLineAndPause

Display message and new line, then wait for enter to be pressed.

    Enter:
      $Message = message to display
    Exit:
      1 if no abort message input
      undef if abort message detected.

DisplayMessage

Output optional timestamp followed by $message

    Enter:
      $message = message to output.
    Exit:
      none.

GetDateString

Returns a string consisting of the current date and time.

    Enter:
      none.
    Exit:
      returns current date and time in the following
      format:

        YYYYMMDDhhmmss

newLine

Output newline sequence.

    Enter:
      $newline = optional newline sequence.
    Exit:
      $newline.

    $newline sequence is output.

Pause

Wait for enter key or end message.

    Enter:
      none
    Exit:
      0 if current end message entered
      1 otherwise.

timestampLine

Output optional timestamp followed by $message followed by newline.

    Enter:
      $message = message to output.
    Exit:
      none.

timestampLineAndPause

Included for backwards compatability. Refer to DisplayLineAndPause

timestampMessage

Output optional timestamp followed by $message.

    Enter:
      $message = message to output.
    Exit:
      none.

timestampMessageAndPause

Included for backwards compatability. Refer to DisplayAndPause

trimMessage

trim $message to the specified length

    Enter:
      $message = message to trim
      $messageLength = length to trim message to
    Exit:
      $message with length $messageLength or less.

    Note:
      if length($message) <= $messageLength, the message
        is NOT lengthened.
      if $messageLength is not supplied, the chomp'ed message
        is returned.

PUBLIC ATTRIBUTES

debug

Set/get the current debug setting.

    Enter:
      $debug = new debug setting (or undef to return current without changing)
    Exit:
      $debug = current debug setting.

endphrase

Set/get the current accept program end message.

    Enter:
      $phrase = new end phrase (or undef to return current without changing)
    Exit:
      $phrase = current end phrase.

htmlFormat

Set/get the current htmlFormat setting.

    Enter:
      $htmlformat = 1 to format for html output. (default = 0).
    Exit:
      $htmlformat = current value.

    if $htmlformat is not defined on input the current value is not modified.

Revision

The Revision method returns the revision number of baseIO.pm:

      $revision = $baseIO->Revision;

    Enter:
      none.
    Exit:
      current revision string.

timestamp

Set/get the current timestamp setting.

    Enter:
      $timestamp = 1 to set, 0 to reset.
    Exit:
      current $timestamp

traceType

Set/get the current trace type.

    Enter:
      $baseIOtype = value of new trace type:
                     0 = console
                     1 = log file only
                     2 = console and log file
    Exit:
      $baseIOtype = current trace type

    if $baseIOtype is already 1 or 2, the log file will be closed prior to
    changing the current $baseIOtype.

Version

The Version method returns the version number of baseIO.pm:

      $version = $baseIO->Version;

    Enter:
      none.
    Exit:
      current version string.

PRIVATE METHODS

These methods are intended for internal use and for use by derived classes.

_accept

Input from console and return buffer.

    Enter:
      $programend = end string
    Exit:
      $inputbuffer = input data buffer

_display

Output $self->{_outputbuffer}

    Enter:
      none.
    Exit:
      none.

_displayline

Display the contents of $message followed by newline. If $timestamp is set, first output a string representing the current time.

    Enter:
      none.
    Exit:
      none.

_displaymessage

Output optional timestamp followed by $message

    Enter:
      none.
    Exit:
      none.

_displaytimestamp

Output timestamp followed by $message

    Enter:
      none.
    Exit:
      none.

AVAILABILITY

baseIO.pm is available from

  http://ewsperl.sourceforge.net/baseIO.html

AUTHOR

Jay Wheeler, EarthWalk Software.

HISTORY

Refer to the Changes file included in the release/snapshot package.

COPYRIGHT

baseIO.pm is copyright © 2002. EarthWalk Software.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA, or get a copy here:

    http://www.fsf.org/licenses/licenses.html#LGPL