Dec 132017
 
TP4 set of I/O routines, not bad.
File TURBOIO.ZIP from The Programmer’s Corner in
Category Pascal Source Code
TP4 set of I/O routines, not bad.
File Name File Size Zip Size Zip Type
!READ.ME 354 257 deflated
DATE20.INC 13056 2792 deflated
IO20.INC 22277 4646 deflated
IO20DEMO.COM 29668 17685 deflated
IO20DEMO.DOC 10240 3508 deflated
IO20DEMO.PAS 17664 4004 deflated
TURBO 50003 47711 deflated

Download File TURBOIO.ZIP Here

Contents of the IO20DEMO.DOC file


DOCUMENTATION FOR IO20DEMO.PAS/COM -- 5/2/86

Bill Meacham
1004 Elm Street
Austin, Tx 78703

PUBLIC DOMAIN -- NO COPYRIGHT

This program demonstrates a sophisticated method of controlling
console data entry in Turbo Pascal. It allows you precise
control over where data entry occurs on the screen and makes your
programs crash-proof from user input. All the I/O (input/output)
routines except for dates are in the Include file IO20.INC.

It also demonstrates a number of ways to manipulate and perform
calculations with dates. All the date routines are in the
Include file DATE20.INC. If you use this file, you must include
IO20.INC first.

Put the compiler toggles {$C-,V-} at the top of your program,
before the Include files. $C- disables checking for control-C
and makes the program run a bit faster. $V- allows you to use
strings of varying lengths.

The rest of this document describes the two Include files.


DOCUMENTATION FOR IO20.INC --------------------------------------------

The functions and procedures in this Include module allow you to
control console I/O with great precision. You can read and write
strings, integers, reals and booleans at any place on the screen
and prevent the user from entering garbage. User input cannot
crash your program! You can easily control cursor movement
through data entry forms displayed on the screen, not only from
field to field but from screen to screen.

The data input procedures, READ_STR, READ_INT, etc., have an
intentional side-effect on the global variable FLD, which
controls which field the cursor goes to. Study the code in
procedures STRINGS, INTEGERS, REALS and BOOLEANS in the
demonstration program to see how a case statement within a
repeat-until loop uses this variable. Study the code in
procedure IO_DEMO in the demonstration program to see how a
similar case statement within a repeat-until loop uses the global
variable SCRN to control which screen is displayed.

The rest of this section describes the global types, variables,
procedures and functions that you can call from your program.
(There are a few more that are used by these procedures and
functions, but are not intended to be called by themselves.)


GLOBAL TYPES AND VARS

type
STR_TYPE = string[80] ;

var
FLD, SCRN : integer ; { For field & screen cursor control. }


PROCEDURES AND FUNCTIONS

procedure BEEP ;
Sounds the console bell.

function CHOPCH (instr:str_type ; inchar:char) : str_type ;
Chops trailing instances of the character from the string.

procedure CLREOL ;
Built-in proc in Turbo to clear screen to end of line.

procedure CLRLINE (col,row : integer) ;
Clears screen to end of line starting at column and row specified.

procedure CLRSCR ;
Built-in procedure in Turbo to clear screen and place cursor at
upper left.

procedure DO_SCRN_CTL ;
Checks value of FLD and adjusts value of SCRN accordingly. Upon
exit SCRN is either one less than it used to be, one more, or
maxint. If it is maxint you should exit from the series of screens.

function EQUAL (r1,r2 : real) : boolean ;
Tests functional equality of two real numbers (floating point, not
BCD). Returns true if r1 equals r2 to a tolerance of 1/100,000.

procedure GOTOXY (col,row:integer) ;
Built-in procedure in Turbo to place cursor on screen at column
(horizontal) and row (vertical) position specified. Upper left is
(1,1) not (0,0).

function GREATER (r1,r2 : real) : boolean ;
Tests functional inequality of two real numbers (floating point, not
BCD). Returns True of r1 is greater than r2 to a tolerance of
1/100,000.

procedure HARD_PAUSE ;
Displays message on line 24, "PRESS SPACE BAR TO CONTINUE OR UP-ARROW
TO GO BACK." Cursor can go forward only if user presses space bar.
Cursor movement back and ESC key are enabled as well.

procedure KEYIN (var ch:char) ;
Accepts one character from the keyboard without echoing it back.
Translates certain control characters and function keys to cursor
control keys recognized by the read_xxx procedures.

procedure PAUSE ;
Displays message on line 24, "PRESS SPACE BAR TO CONTINUE." Cursor
goes forward only if user presses space bar. Cursor movement back
is disabled, but ESC is recognized.

function PURGECH (instr : str_type ; inchar : char) : str_type ;
Purges all instances of the character from the string.

procedure READ_BOOL (var bool:boolean; col,row:integer) ;
Displays boolean at column and row specified, inputs "Y"
or "N" to set new value of boolean, prints "YES" or "NO."
Note -- use this when the screen control may return to the
question and the boolean IS defined before the user answers
the question. Does affect global FLD.

procedure READ_INT (var int:integer ; maxlen, col, row:integer) ;
Reads an integer from the keyboard, rejects invalid data. COL and
ROW tell where to begin the data input field, and MAXLEN is the
maximum length of the character representation of the integer,

procedure READ_REAL (var r:real ; maxlen,frac,col,row:integer) ;
Reads a real number from the keyboard, rejects invalid data. COL
and ROW tell where to begin the data input field; MAXLEN is the
maximum length of the string representation of the real number,
including sign and decimal point; FRAC is the fractional part, the
number of digits to right of the decimal point. Designed to work
with floating point (not BCD) reals, but could work with BCDs as
well. Note -- In Turbo the maximum number of significant digits in
a floating point real is 11. It is the programmer's responsibility
to limit input and computed output to 11 significant digits.

procedure READ_STR (var st:str_type ; maxlen, col, row:integer) ;
Reads a string from the keyboard, rejects invalid data. COL and ROW
tell where to begin the data input field, and MAXLEN is the maximum
length of the string.

procedure READ_YN (var bool:boolean; col,row:integer) ;
Inputs "Y" OR "N" to boolean at column and row specified,
prints "YES" or "NO."
Note -- use this when the screen control will not return
to the question and the boolean IS NOT defined before the
user answers the question. Does not affect global FLD.

procedure SHOW_MSG (msg : str_type) ;
Beeps, displays message centered on line 23, pauses (calls proc
Pause).

function STRIPCH (instr:str_type ; inchar:char) : str_type ;
Strips leading instances of the character from the string.

procedure WRITE_BOOL (bool:boolean ; col, row:integer) ;
Writes "YES" or "NO " at the column and row specified, depending on
value of the boolean.

procedure WRITE_INT (int:integer ; width,col,row:integer) ;
Writes the integer, right-justified in a field WIDTH characters
wide, at the column and row specified.

procedure WRITE_REAL (r:real ; width,frac,col,row:integer) ;
Writes the real, right-justified in decimal format with FRAC digits
to the right of the decimal point in a field WIDTH wide, at the
column and row specified.

procedure WRITE_STR (st:str_type ; col,row:integer) ;
Writes the string at the column and row specified.


DOCUMENTATION FOR DATE20.INC ------------------------------------------

The functions and procedures in this Include file allow you to
read and write dates in a fashion similar to reading and writing
strings, integers, reals and booleans. You can also perform
number of other functions on dates, such as count the number of
days between two dates, test for leapyear, compute the previous
and next day, etc. If you include this file, include IO20.INC
first.


GLOBAL TYPES AND CONSTANTS

type
DATE = record
yr : integer ; { 0 .. 9999 }
mo : integer ; { 1 .. 12 }
dy : integer ; { 1 .. 31 }
end ;

DATESTRING = string[10] ; { 'MM/DD/YYYY' }

JULDATE = record
yr : integer ; { 0 .. 9999 }
day : integer ; { 1 .. 366 }
end ;

JULDATESTRING = string[8] ; { 'YYYY/DDD' }

const
NULL_DATE : date = (yr:0 ; mo:0 ; dy:0) ;
NULL_DATE_STR : datestring = 'MM/DD/YYYY' ;


PROCEDURES AND FUNCTIONS

function DATE_DIFF (dt1, dt2 : date) : real ;
Computes the number of days between two dates.

function EQUAL_DATE (dt1, dt2 : date) : boolean ;
Returns True if dt1 is equal to dt2, else False.

function GREATER_DATE (dt1, dt2 : date) : integer ;
Compares two dates, returns 0 if both equal, 1 if first is
greater, 2 if second is greater.

procedure GREG_TO_JUL (dt : date ; var jdt : juldate) ;
Converts a gregorian date to a julian date.

procedure JUL_TO_GREG (jdt : juldate ; var dt : date) ;
Converts a julian date to a gregorian date.

function LEAPYEAR (yr : integer) : boolean ;
Returns True if the year is a leap year, else False. The
year is year and century, e.g. year 1984 is '1984,' not '84.'

function MK_DT_ST (dt : date) : datestring ;
Makes a string out of a date -- used for printing dates.

function MK_JUL_DT_ST (jdt : juldate) : juldatestring ;
Makes a string out of a julian date.

function MONTH_DIFF (dt1, dt2 : date ) : integer ;
Computes number of months between two dates, rounded.

procedure NEXT_DAY (var dt : date) ;
Adds one day to the date.

procedure PREV_DAY (var dt : date) ;
Subtracts one day from the date.

procedure READ_DATE (var dt: date ; col, row: integer) ;
Read date at column and row specified. If the user enters
only two digits for the year, the procedure plugs the century
as 1900 for years from 80 to 99 or 2000 for years from 00 to
79, but the user can enter all four digits to override the
plug.

function VALID_DATE (dt:date) : boolean ;
Returns True if the date is a valid date, else False.

procedure WRITE_DATE (dt: date ; col, row: integer) ;
Writes date at column and row specified.
not '84.'

function MK_DT_ST (dt : date) : datestring


 December 13, 2017  Add comments

Leave a Reply