Category : Pascal Source Code
Archive   : ASG53.ZIP
Filename : BLUEBAG.DOC
Routines are available for modifying the cursor, CRT tricks, dates, string
processing, testing printer status, and multiple overlapping windows. This
updated unit was partly rewritten in Assembler for reduced size and faster
performance. Desirable in itself this unit is essential for the AtSayGet
line editing procedures available in the ASG53.ARC file. The interface is
noted below (routines grouped by function) followed by an alphabetical
listing and explanation of each routine.
{$R-,V-,B-}
UNIT BlueBag;
INTERFACE
USES
Crt,
DOS;
TYPE
Xrange=1..80;
Yrange=1..25;
LptRange=0..2;
Date = LONGINT;
DateString = STRING[8];
DelimitedDate = STRING[10];
DofW = 1..7;
MofY = 1..12;
CONST
IsColor : BOOLEAN=True; {Display mode at startup}
BadDate = $7FFFFFFF;
VAR
StartScan,
StopScan : BYTE; {Cursor shape at startup}
OrgAttr,
SayAttr,
GetAttr,
EndAttr : BYTE; {AtSayGet attribute bytes}
(* 10 CRT procedures *)
PROCEDURE CursorSave; {obj code}
PROCEDURE CursorOn; {obj code}
PROCEDURE CursorOff; {obj code}
PROCEDURE RestoreCursor; {obj code}
PROCEDURE SetCursor(ScanStart,ScanStop:BYTE); {obj code}
PROCEDURE Center(Row:YRange; Mid:STRING);
PROCEDURE CLEAR(X1,Y1,X2,Y2:INTEGER);
PROCEDURE DrawBox(X1,Y1,X2,Y2,LineStyle:BYTE);
PROCEDURE RestoreVideo;
PROCEDURE ReverseVideo;
(* 12 DATE functions *)
FUNCTION DateStringToDate(DS:DateString):Date;
FUNCTION DateToDateString(DT:Date):DateString;
FUNCTION DayOfWeek(DT:Date):DofW;
FUNCTION DaysBetween(Early,Late:Date):LongInt;
FUNCTION DelimitDateString(DS:DateString):DelimitedDate;
PROCEDURE IncDate(VAR DT:Date; Delta:LongInt);
FUNCTION MonthOfYear(DT:Date):MofY;
FUNCTION NameOfDay(DayNdx:DofW):STRING;
FUNCTION NameOfMonth(MoNdx:MofY):STRING;
FUNCTION StripDateString(DS:DelimitedDate):DateString;
FUNCTION SysDate:Date;
FUNCTION ValidDate(DS:DateString):BOOLEAN;
(* 11 STRING routines *)
FUNCTION IsBlank(TestStr:STRING):BOOLEAN;
PROCEDURE NoBlanks(VAR HasBlanks:STRING);
FUNCTION Trim(LongLine:STRING):STRING;
FUNCTION UpperCase(S:STRING):STRING; {obj code}
FUNCTION LowerCase(S:STRING):STRING; {obj code}
FUNCTION LoCase(C:CHAR):CHAR;
PROCEDURE WAIT;
PROCEDURE RealToEnglish(Numeric:REAL; VAR Anglo:STRING);
FUNCTION NextWord(WordStr:STRING):STRING;
PROCEDURE GetWordCount(WordStr:STRING; VAR WordCount:BYTE);
FUNCTION NthWord(WordStr : STRING;
Nth : BYTE ) : STRING;
(* 3 DEVICE functions *)
FUNCTION OnFile(FileName:STRING):BOOLEAN;
FUNCTION PrinterOnLine(LPTnum:LptRange):BOOLEAN; {obj code}
PROCEDURE PrtSc;
(* 2 WINDOW procedures *)
PROCEDURE OpenWindow(TX:Xrange; TY:Yrange; BX:Xrange; BY:Yrange;
FRG,BKG,Border : BYTE;
Heading : STRING);
PROCEDURE CloseWindow;
(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
Alphabetical listing of the 37 BLUEBAG routines and an explanation
of the purpose of each:
CENTER writes on ROW the string passed to it. The string is centered on
the screen or in the window.
CLEAR clears screen area defined by the coordinates using current text
attribute. It is relative to any window that may be open.
eg: Clear(5,5,10,10); {clears screen fron 5,5, to 10,10}
CLOSEWINDOW restores the image under the current window and frees the heap
space that was used to store it.
eg: CloseWindow; {closes the last window that was opened}
CURSOROFF turns off the cursor after saving the current cursor shape in
StartScan and StopScan. A call to RESTORECURSOR will reset it to its shape
before being turned off.
eg: CursorOff; {hides the cursor}
CURSORON sets the cursor to the default setting for the monitor in use at
startup.
eg: CursorOn; {turns on the cursor}
CURSORSAVE saves the current cursor start and stop scan lines into the global
variables StartScan and StopScan.
eg: CursorSave; {saves the cursor shape}
DATESTRINGTODATE returns a (LongInt) Date from a (STRING[8]) DateString.
eg: DateToDateString('07041776') returns 648869 in a 4 byte LongInt.
DATETODATESTRING returns a (STRING[8]) DateString from a (LongInt) Date.
eg: DateToDateString(648869) returns '07041776'.
DAYSBETWEEN returns the number of days between the early and late dates.
eg: DaysBetween(DateStringToDate('07041776'),DateToDateString('07041989'))
returns 77,796 (days).
DAYOFWEEK returns the ordinal day of week from a LongInt Date; 1=Saturday,
2=Sunday, 3=Monday, 4=Tuesday, 5=Wednesday, 6=Thursday, and 7=Friday.
eg: CanadaDay:DateString='07011867';
DayOfWeek(DateStringToDate(CanadaDay)) returns 4 and
NameOfDay(4) returns 'Tuesday'.
DRAWBOW draws a box defined by the coordinates. LineStyles are 1 (single),
2 (double), (3, 4 are mixed ), or 32..254 (ASCII #32..#254).
eg: DrawBox(5,5,10,10,219); {draws a box from 5,5, to 10,10 in CHR(219) = Û }
DELIMITDATESTRING returns a (STRING[10]) DelimitedDate from a (STRING[8])
DateString. The resulting date string is delimited with slashes.
eg: DelimitDateString('07011867') returns '07/01/1867'
DelimitDateString(DateToDateString(648869)) returns '07/04/1776'.
GETWORDCOUNT Returns the number of words in a string.
eg: WordCount('Short and sweet') returns 3
INCDATE incriments a (LongInt) Date by delta days.
ISBLANK returns True if the string has is nul or all spaces, or False if the
string has at least one character.
eg: IsBlank('Something is here') is False; IsBlank(' ') is True;
LOWERCASE returns a string in lowercase.
eg: LowerCase('SMALL IS BEAUTIFUL') = 'small is beautiful'
MONTHOFYEAR returns the ordinal month of a (LongInt) Date.
eg: MonthOfYear(648869) gives 7
NameOfMonth(7) returns 'July'
NAMEOFDAY returns the name of the day in English.
For an example see: DAYOFWEEK.
NAMEOFMONTH returns the name of the month in English.
For an example see MONTHOFYEAR.
NEXTWORD Returns the next word from a string.
NOBLANKS removes all blanks from a string.
eg: SomeStr:STRING='JUNK 1 ';
SomeStr:=SomeStr+'.BAK'; (* Now SomeStr = 'JUNK 1 .BAK' *)
NoBlanks(SomeStr); (* Now SomeStr = 'JUNK1.BAK' *)
NTHWORD Returns the Nth word in a string.
eg: NthWord('This is short and Sweet',3) returns 'short'
ONFILE returns True if specified file exists. FileName defaults to the current
directory or looks to the path specified.
eg: OnFile('\UTIL\PCTOOLS.EXE') OR OnFile('PCTOOLS.EXE') results in True if
PCTOOLS.EXE is in the \util or current directory, otherwise returns False.
OPENWINDOW first stores the screen display within the coordinates specified
and saves the image on the heap. It then draws a border using a border style
and TextAttrs specified in the parameters. An optional title is permitted at
the top of the window. A window is then opened within the border and the
screen cleared. Up to 9 windows may be opened and they can overlap.
eg: OpenWindow(5,5,50,12,White,Red,1,' HI MOM ') draws a single line frame
in white on a red background from 5,5 to 50,12 and opens a window within
the borders. The words ' HI MOM ' are centered at the top of the border.
PRINTERONLINE returns True if printer port status reports ready, else False.
LPTnum RANGE IS 0..2 corresponding to the printer ports 1..3
eg: PrinterOnLine(0) is False if you don't have a printer on port 1 or if you
do but the printer is off line. Tests out fine on Epson but other printers
may not respond as expected.
PROCEDURE PrtSc will print the screen to PRN as though the user had pushed
the PrtSc key. It is desirable to determine that PrinterOnLine(0)=True before
calling this procedure. Note that this procedure (very new to these units)
has not been demonstrated in the DEMO.PAS program but try it out yourself.
REALTOENGLISH Takes a REAL value (Numeric) and outputs the English words
that represent the Numeric in a STRING variable (Anglo). The maximum value
that can be translated is $9,999,999.99
RESTORECURSOR restores the cursor to the shape it had before being turned off
by the CursorOff procedure or modified by the SetCursor procedure.
eg: RestoreCursor;
RESTOREVIDEO restores the video attribute to the condition before calling the
ReverseVideo procedure (See below).
REVERSEVIDEO displays black charactors on light background on a mono screen;
On color screens it displays a suitable dark colored charactor on light b/g.
SETCURSOR sets cursor start and stop scans for altering cursor shape.
SetCursor(StartScan,StopScan) will always display a block cursor regardless of
the monitor used.
eg: SetCursor(5,6); { If used on a mono screen the cursor will be a dash "-" }
STRIPDATESTRING removes the delimitors (usually a slash) from a (STRING[10])
delimitedDate and returns a (STRING[8]) DateString.
eg: StripDateString('01/01/1989') returns '01011989'
StripDateString('01.01.1989') returns '01011989' also.
SYSDATE returns a (Longint) Date from the system clock; The result varies
depending on the system date.
TRIM returns a string with any leading or trailing spaces removed.
eg: Tight:=Trim(' and then she said '); { Tight = 'and then she said' }
UPPERCASE returns a string in uppercase. Corrected version of assembly code
listed on pgs 213-4 of the TP5 manual.
eg: Uppidy:=UpperCase('and then she said'); { Uppidy='AND THEN SHE SAID' }
VALIDDATE returns True if the DateString is valid, else False.
eg: ValidDate('02291988') returns True but
ValidDate('02291989') returns False (because 1989 is not a leapyear).
WAIT turns off cursor, prints the message 'Press any key to continue' at the
current cursor location, waits for any key to be pressed, and then restores
the cursor.
eg: Wait; { Displays: Press any key to continue }
(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *)
{See Demo.pas for some examples of how to use the routines in this unit}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/