baseIO.pm -- common input/output and simple tracing object.
Version 1.00
4/20/2002
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;
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.
$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.
Accept input message.
Enter:
$programEnd = word or phrase to enter to end program.
Exit:
$inputBuffer = chomp-ed input buffer
undef if user enters $programEnd.
Output $message
Enter:
$message = message to output.
Exit:
none.
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.
Display message then wait for enter to be pressed.
Enter:
$Message = message to display
Exit:
none.
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
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.
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.
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.
Output optional timestamp followed by $message
Enter:
$message = message to output.
Exit:
none.
Returns a string consisting of the current date and time.
Enter:
none.
Exit:
returns current date and time in the following
format:
YYYYMMDDhhmmss
Output newline sequence.
Enter:
$newline = optional newline sequence.
Exit:
$newline.
$newline sequence is output.
Wait for enter key or end message.
Enter:
none
Exit:
0 if current end message entered
1 otherwise.
Output optional timestamp followed by $message followed by
newline.
Enter:
$message = message to output.
Exit:
none.
Included for backwards compatability. Refer to DisplayLineAndPause
Output optional timestamp followed by $message.
Enter:
$message = message to output.
Exit:
none.
Included for backwards compatability. Refer to DisplayAndPause
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.
Set/get the current debug setting.
Enter:
$debug = new debug setting (or undef to return current without changing)
Exit:
$debug = current debug setting.
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.
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.
The Revision method returns the revision number of baseIO.pm:
$revision = $baseIO->Revision;
Enter:
none.
Exit:
current revision string.
Set/get the current timestamp setting.
Enter:
$timestamp = 1 to set, 0 to reset.
Exit:
current $timestamp
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.
The Version method returns the version number of baseIO.pm:
$version = $baseIO->Version;
Enter:
none.
Exit:
current version string.
These methods are intended for internal use and for use by derived classes.
Input from console and return buffer.
Enter:
$programend = end string
Exit:
$inputbuffer = input data buffer
Output $self->{_outputbuffer}
Enter:
none.
Exit:
none.
Display the contents of $message followed by newline. If
$timestamp is set, first output a string representing the
current time.
Enter:
none.
Exit:
none.
Output optional timestamp followed by $message
Enter:
none.
Exit:
none.
Output timestamp followed by $message
Enter:
none.
Exit:
none.
baseIO.pm is available from
http://ewsperl.sourceforge.net/baseIO.html
Jay Wheeler, EarthWalk Software.
Refer to the Changes file included in the release/snapshot package.
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