home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
pascal
/
shdk_1.zip
/
SKYHAWK.RR
< prev
next >
Wrap
Text File
|
1992-03-26
|
114KB
|
3,362 lines
$$IndexTag = ƒ
ƒUNIT ƒDEPENDENCIES
.
D S S T T T T T T
O H H P P P P P P
S L U C D I M S W
| I T R O N E T I
+--uses--> | S I T S L M R N
| | T L | | I C I D
| | | P | | N H N O
| | | K | | E K G W
| | | | | | | | | |
ƒShƒClrDef - - - X - - - - X
ƒShƒCmdLin X X X - - - - - -
ƒShƒCmplx - - - - - - - - -
ƒShƒCrcChk X - - - - - - - -
ƒShƒDatPk X - - - - - - - -
ƒShƒErrMsg - - - - - - - - -
ƒShƒList - - - - - X X X -
ƒShƒLngStr - - - - - X X X -
ƒShƒUtilPk - - - - X - - X -
unit ƒShƒClrDef
{Black text} {Blue text}
ƒBlackOnBlack = ƒ$00; ƒBlueOnBlack = ƒ$01;
ƒBlackOnBlue = ƒ$10; ƒBlueOnBlue = ƒ$11;
ƒBlackOnGreen = ƒ$20; ƒBlueOnGreen = ƒ$21;
ƒBlackOnCyan = ƒ$30; ƒBlueOnCyan = ƒ$31;
ƒBlackOnRed = ƒ$40; ƒBlueOnRed = ƒ$41;
ƒBlackOnMagenta = ƒ$50; ƒBlueOnMagenta = ƒ$51;
ƒBlackOnBrown = ƒ$60; ƒBlueOnBrown = ƒ$61;
ƒBlackOnLtGray = ƒ$70; ƒBlueOnLtGray = ƒ$71;
unit ƒShƒClrDef
{Green text} {Cyan text}
ƒGreenOnBlack = ƒ$02; ƒCyanOnBlack = ƒ$03;
ƒGreenOnBlue = ƒ$12; ƒCyanOnBlue = ƒ$13;
ƒGreenOnGreen = ƒ$22; ƒCyanOnGreen = ƒ$23;
ƒGreenOnCyan = ƒ$32; ƒCyanOnCyan = ƒ$33;
ƒGreenOnRed = ƒ$42; ƒCyanOnRed = ƒ$43;
ƒGreenOnMagenta = ƒ$52; ƒCyanOnMagenta = ƒ$53;
ƒGreenOnBrown = ƒ$62; ƒCyanOnBrown = ƒ$63;
ƒGreenOnLtGray = ƒ$72; ƒCyanOnLtGray = ƒ$73;
unit ƒShƒClrDef
{Red text} {Magenta text}
ƒRedOnBlack = ƒ$04; ƒMagentaOnBlack = ƒ$05;
ƒRedOnBlue = ƒ$14; ƒMagentaOnBlue = ƒ$15;
ƒRedOnGreen = ƒ$24; ƒMagentaOnGreen = ƒ$25;
ƒRedOnCyan = ƒ$34; ƒMagentaOnCyan = ƒ$35;
ƒRedOnRed = ƒ$44; ƒMagentaOnRed = ƒ$45;
ƒRedOnMagenta = ƒ$54; ƒMagentaOnMagenta = ƒ$55;
ƒRedOnBrown = ƒ$64; ƒMagentaOnBrown = ƒ$65;
ƒRedOnLtGray = ƒ$74; ƒMagentaOnLtGray = ƒ$75;
unit ƒShƒClrDef
{Brown text} {Light Gray text}
ƒBrownOnBlack = ƒ$06; ƒLtGrayOnBlack = ƒ$07;
ƒBrownOnBlue = ƒ$16; ƒLtGrayOnBlue = ƒ$17;
ƒBrownOnGreen = ƒ$26; ƒLtGrayOnGreen = ƒ$27;
ƒBrownOnCyan = ƒ$36; ƒLtGrayOnCyan = ƒ$37;
ƒBrownOnRed = ƒ$46; ƒLtGrayOnRed = ƒ$47;
ƒBrownOnMagenta = ƒ$56; ƒLtGrayOnMagenta = ƒ$57;
ƒBrownOnBrown = ƒ$66; ƒLtGrayOnBrown = ƒ$67;
ƒBrownOnLtGray = ƒ$76; ƒLtGrayOnLtGray = ƒ$77;
unit ƒShƒClrDef
{Dark Gray text} {Light Blue text}
ƒDkGrayOnBlack = ƒ$08; ƒLtBlueOnBlack = ƒ$09;
ƒDkGrayOnBlue = ƒ$18; ƒLtBlueOnBlue = ƒ$19;
ƒDkGrayOnGreen = ƒ$28; ƒLtBlueOnGreen = ƒ$29;
ƒDkGrayOnCyan = ƒ$38; ƒLtBlueOnCyan = ƒ$39;
ƒDkGrayOnRed = ƒ$48; ƒLtBlueOnRed = ƒ$49;
ƒDkGrayOnMagenta = ƒ$58; ƒLtBlueOnMagenta = ƒ$59;
ƒDkGrayOnBrown = ƒ$68; ƒLtBlueOnBrown = ƒ$69;
ƒDkGrayOnLtGray = ƒ$78; ƒLtBlueOnLtGray = ƒ$79;
unit ƒShƒClrDef
{Light Green Text} {Light Cyan text}
ƒLtGreenOnBlack = ƒ$0A; ƒLtCyanOnBlack = ƒ$0B;
ƒLtGreenOnBlue = ƒ$1A; ƒLtCyanOnBlue = ƒ$1B;
ƒLtGreenOnGreen = ƒ$2A; ƒLtCyanOnGreen = ƒ$2B;
ƒLtGreenOnCyan = ƒ$3A; ƒLtCyanOnCyan = ƒ$3B;
ƒLtGreenOnRed = ƒ$4A; ƒLtCyanOnRed = ƒ$4B;
ƒLtGreenOnMagenta = ƒ$5A; ƒLtCyanOnMagenta = ƒ$5B;
ƒLtGreenOnBrown = ƒ$6A; ƒLtCyanOnBrown = ƒ$6B;
ƒLtGreenOnLtGray = ƒ$7A; ƒLtCyanOnLtGray = ƒ$7B;
unit ƒShƒClrDef
{Light Red text} {Light Magenta text}
ƒLtRedOnBlack = ƒ$0C; ƒLtMagentaOnBlack = ƒ$0D;
ƒLtRedOnBlue = ƒ$1C; ƒLtMagentaOnBlue = ƒ$1D;
ƒLtRedOnGreen = ƒ$2C; ƒLtMagentaOnGreen = ƒ$2D;
ƒLtRedOnCyan = ƒ$3C; ƒLtMagentaOnCyan = ƒ$3D;
ƒLtRedOnRed = ƒ$4C; ƒLtMagentaOnRed = ƒ$4D;
ƒLtRedOnMagenta = ƒ$5C; ƒLtMagentaOnMagenta = ƒ$5D;
ƒLtRedOnBrown = ƒ$6C; ƒLtMagentaOnBrown = ƒ$6D;
ƒLtRedOnLtGray = ƒ$7C; ƒLtMagentaOnLtGray = ƒ$7D;
unit ƒShƒClrDef
{Yellow text} {White text}
ƒYellowOnBlack = ƒ$0E; ƒWhiteOnBlack = ƒ$0F;
ƒYellowOnBlue = ƒ$1E; ƒWhiteOnBlue = ƒ$1F;
ƒYellowOnGreen = ƒ$2E; ƒWhiteOnGreen = ƒ$2F;
ƒYellowOnCyan = ƒ$3E; ƒWhiteOnCyan = ƒ$3F;
ƒYellowOnRed = ƒ$4E; ƒWhiteOnRed = ƒ$4F;
ƒYellowOnMagenta = ƒ$5E; ƒWhiteOnMagenta = ƒ$5F;
ƒYellowOnBrown = ƒ$6E; ƒWhiteOnBrown = ƒ$6F;
ƒYellowOnLtGray = ƒ$7E; ƒWhiteOnLtGray = ƒ$7F;
unit ƒShƒClrDef
ƒOrientation = (ƒVertical, ƒHorizontal);
unit ƒShƒClrDef
ƒSELECTCOLORS
Declarations:
function SelectColors(Row, Col, BegAttr : byte;
CpFrameChars : FrameArray;
Orient : Orientation;
ErasePanelOnExit,
EraseCursorOnExit,
WrapCursor : boolean;
Header : string) : byte;
.
Purpose:
Displays a color selection panel, permitting the user to
move a special cursor using the arrow keys and select a desired
color combination using the <CR> key.
.
Comments:
The user navigates the panel with the arrow keys and selects
the desired color combination by pressing <CR>. The attribute
byte value currently under the cursor will be returned. The user
can also press <INS>, which will return a function value of $FF,
and by convention, should be taken to indicate that the currently
selected attribute value is to be unchanged. Additionally, the
user can press <ESC>, returning a function value of $FE, which by
convention should be taken to indicate that the current color
selection run is completed. Finally, a return of $FD indicates
that the user has pressed the <F1> key either alone or in
combination with one of the shift-type keys (<L-SHIFT>, <R-
SHIFT>, <CTRL>, or <ALT>), and by convention indicates that the
user is requesting help.
.
The function performs the following actions:
.
* Displays a 16x8 panel of text colors with the window
coordinates of the upper left corner at coordinates X=Col,
Y=Row.
.
* The attribute at which the cursor will be initially placed
is at BegAttr.
.
* The color panel will be framed using the characters
specified in CpFrameChars.
.
* The orientation of the long dimension of the selection
panel is determined as specified by Orient.
.
* ErasePanelOnExit determines whether the panel is erased or
preserved on the screen when SelectColors returns to the
caller. The panel is always disposed, and its heap space
reclaimed.
.
* EraseCursorOnExit is only effective if ErasePanelOnExit is
false. If the panel is to be preserved between calls to
SelectColors, EraseCursor determines whether the or not
the cursor will continue to be displayed along with the
panel.
.
* WrapCursor determines whether the cursor will wrap both
horizontally and vertically. True allows the cursor to
wrap; False inhibits further cursor movement when a window
edge is reached.
.
* Header is the header line which will be displayed on the
panel. It can be supplied as an empty string (''), in
which case no header will be displayed.
.
* The function returns a normal text attribute byte, with
the following exceptions:
.
Return Explanation
------ -----------
$FF <INS> was pressed by the user. Leave the
current value unchanged.
$FE <ESC> was pressed by the user. Accept all
current values and consider the run
completed.
$FD <F1> was pressed by the user. Provide a
HELP screen or message.
$F0 Error in MakeWindow
$F1 Error in DisplayWindow
unit ƒShƒClrDef
ƒCOLORNAME
Declarations:
function ColorName(Attr : byte) : string;
.
Purpose:
Given a text attribute byte, ColorName returns the attribute
color name as defined above; e.g., ColorName($1E) will return
'YellowOnBlue'.
.
Comments:
If a byte value is passed which does not correspond to a
valid text attribute, an empty string is returned.
.
Examples:
The statement
.
WriteLn(ColorName($73));
.
displays the string
.
CyanOnLtGray
.
on the screen.
unit ƒShƒCmdLin
ValueType = (VtStr, VtReal, VtInt);
SwRec = record
Name : string;
case SwVal : ValueType of
VtStr : (StrVal : string);
VtReal: (RealVal: Extended);
VtInt : (IntVal : integer);
end; {SwRec}
CharSet = Set of Char;
unit ƒShƒCmdLin
ƒCLCLOSE
Declarations:
procedure ClClose;
.
Purpose:
Closes the internal data structures and frees the space
associated with the command line switch list.
.
Comments:
If GetSwitch is used to retrieve switch values, ClClose
should be called following retrieval of the last switch. If
PopSwitch is used, ClClose need not be called.
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
ClInit GetSwitch PopSwitch
unit ƒShƒCmdLin
ƒCLINIT
Declarations:
procedure ClInit;
.
Purpose:
Initializes the internal data structures used to store the
command line switch list.
.
Comments:
ClInit MUST be called prior to any of the other Cl routines.
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
ClClose
unit ƒShƒCmdLin
ƒCLPARSE
Declarations:
procedure ClParse(StrPtr : Pointer; StrOnly : Boolean;
LeadIn, ValDelim : CharSet; var Err : Integer);
.
Purpose:
To parse a command tail (or other string of similar form),
producing a list of switch names and associated values which can
then be retrieved using the GetSwitch or PopSwitch functions.
.
Comments:
Parsing is accomplished by invoking the procedure ClParse
with five parameters:
.
1. StrPtr of type Pointer is used to point to the string to
be parsed. If StrPtr is NIL, the command tail will be
parsed.
.
2. StrOnly of type Boolean is used to determine if switch
values of type String are to be forced, regardless of the
form of the value. StrOnly = True forces String values.
.
3. LeadIn of type CharSet is used to identify the set of
characters used to mark the beginning of a switch. It is
suggested that LeadIn be set to [ ReadSwCh ]. The weakest
condition used should be that the expression ( ReadSwCh in
LeadIn ) be TRUE.
.
4. ValDelim of type CharSet is used to specify the set of
characters which may be used to separate the switch name
from the switch value.
.
5. Err of type Integer is used to return error conditions.
.
Prior to the call to ClParse, a call MUST be made to ClInit.
.
The procedure prepares a list of records, each record con-
taining the name and value of one command line switch. These
records will require 536 bytes of heap space per switch.
.
All switches (with the optional exception of the first) are
preceded by one of the members of the set LeadIn.
.
Switches may take values of type Real (actually, Extended),
LongInt, or String. In each case, the switch value is separated
from the switch name by one of the characters specified in the
parameter ValDelim. Switches which do not take on any explicit
value will be returned as type String, with a value length of
zero.
.
Assuming StrOnly = FALSE in the call, switches whose VALUE
is intended to be of type String, but with a FORM qualifying as a
numeric, must be enclosed in either single or double quotation
marks. Otherwise, the value will be returned as a Real or
LongInt, as determined by its specific syntax.
.
Additionally, any blanks included in String values will be
packed out unless the value is included in quotation marks.
Further, if single quote marks are to be included as part of a
string value, then double quotes must be used to define the
value; and vice versa.
.
Finally, blanks may be freely entered in the command tail to
improve readability (except as noted above).
.
Error Returns:
The error parameter returns one of three values:
0 --> No error encountered.
1 --> Unbalanced single quotes encountered.
2 --> Unbalanced double quotes encountered.
3 --> Insufficient heap space to store the switch list.
.
Assuming the error return is 0, the list of switches has
been successfully prepared and is available for retrieval using
GetSwitch or PopSwitch.
.
If GetSwitch has been used to retrieve the switch values,
ClClose should be called to release the heap space associated
with the list of switches. This is not necessary if PopSwitch has
been used for retrieval (but it won't hurt anything, either).
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
ClInit ClClose GetSwitch PopSwitch
unit ƒShƒCmdLin
ƒGETSWITCH
Declarations:
function GetSwitch(var Y : SwRec) : boolean;
.
Purpose:
Retrieves the next switch record in the list of switch
records prepared by ClParse. Returns FALSE if no more.
.
Comments:
The list of switches can, if desired, be treated as a ring
(thus enabling switches to be read more than once). If GetSwitch
is called again after returning a function value of FALSE, read-
ing will recommence at the top of the list.
.
Use of GetSwitch and PopSwitch should not be combined. If
they are both used on the same pass through the command tail,
orphan blocks (blocks which have no associated pointer, and thus
cannot be accessed or retrieved) will result on the heap.
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
PopSwitch
unit ƒShƒCmdLin
ƒPOPSWITCH
Declarations:
function PopSwitch(var Y : SwRec) : boolean;
.
Purpose:
Retrieves the next switch record in the list of switch
records prepared by ClParse, and frees its heap space. Returns
FALSE if no more.
.
Comments:
Since PopSwitch frees the heap space associated with each
switch after it has been returned to the caller, it is not
necessary to call ClClose after reaching the end of the switch
list. For the same reason, however, the switch list cannot be
treated as a ring (that is, the switch list cannot be reread
after the end has been reached).
.
Use of GetSwitch and PopSwitch should not be combined. If
they are both used on the same pass through the command tail,
orphan blocks (blocks which have no associated pointer, and thus
cannot be accessed or retrieved) will result on the heap.
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
GetSwitch
unit ƒShƒCmdLin
ƒREADSWCH
Declarations:
function ReadSwCh : char;
.
Purpose:
Returns the current switch lead-in character.
.
Comments:
DOS normally recognizes the character '/' as the switch
lead-in. DOS also permits this character to be changed. In par-
ticular, some installations whose personnel are more comfortable
in a UNIX-like environment have changed the switch lead-in to
'-'. The ReadSwCh function permits the programmer to assure that
the character which DOS recognizes will be included in the set of
permissible lead-in characters which the parser will also
recognize.
.
Examples:
See the files TESTCL.PAS and CLTEST.BAT
.
See also:
SetSwCh
unit ƒShƒCmdLin
ƒSETSWCH
Declarations:
procedure SetSwCh(C : char);
.
Purpose:
Sets the switch lead-in character to C.
.
Comments:
THIS PROCEDURE MODIFIES THE CURRENTLY RUNNING COPY OF DOS.
Therefore it should only be used in exceptional circumstances,
and with great caution. Otherwise the users could be in for quite
a surprise! It is included here primarily for completeness.
.
Examples:
SetSwCh('+');
.
will change the switch lead-in to '+'.
.
See also:
ReadSwCh
unit ƒShƒCmplx
ComplexElement = extended;
ComplexBaseType = record
Re,
Im : ComplexElement;
end;
Complex = ^ComplexBaseType;
unit ƒShƒCmplx
ƒC2P
Declarations:
procedure C2P(A : Complex; var Result : Complex);
function C2PF(A : Complex) : Complex;
.
Purpose:
Transforms a complex in Cartesian form into polar form.
.
Examples:
CpPwrR(C2PF(MyCmpx), 3.0, MyCmpxCubedPolar);
.
Comments:
The magnitude will be stored in Result^.Re and the angle
(expressed in radians) in Result^.Im
.
See Also:
P2C
unit ƒShƒCmplx
ƒCABS
Declarations:
procedure CAbs(A : Complex; var Result : ComplexElement);
function CAbsF(A : Complex) : ComplexElement;
.
Purpose:
Returns the absolute value of a complex number.
.
Examples:
∙∙∙
MyCmpx^.Re := 3.0;
MyCmpx^.Im := 4.0;
∙∙∙
WriteLn(CAbs(MyCmpx):4:1); {will display 5.0}
.
Comments:
Recall that the absolute value of a complex number Re + iIm
is sqrt((Re * Re) + (Im * Im)).
.
See Also:
unit ƒShƒCmplx
ƒCADD
Declarations:
procedure CAdd(A, B : Complex; var Result : Complex);
function CAddF(A, B : Complex) : Complex;
.
Purpose:
Returns the sum of two complex numbers A + B.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
.
See Also:
CSub CMul CDiv
unit ƒShƒCmplx
ƒCCONJ
Declarations:
procedure CConj(A : Complex; var Result : Complex);
function CConjF(A : Complex) : Complex;
.
Purpose:
Returns the complex conjugate of a complex number.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
Recall that if a complex number A = R + Ii, then the complex
conjugate of A is R - Ii.
.
See Also:
unit ƒShƒCmplx
ƒCDIV
Declarations:
procedure CDiv(A, B : Complex; var Result : Complex);
function CDivF(A, B : Complex) : Complex;
.
Purpose:
Returns the quotient of two complex numbers A / B.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
CAbsF(B) must be > 0.0. If CAbsF(B) <= 0.0, CmplxError will
return -1.
.
See Also:
CAdd CMul CSub
unit ƒShƒCmplx
ƒCMP2STR
Declarations:
function Cmp2Str(A : Complex; Width, Places : byte) :
string;
.
Purpose:
Converts a complex value to a string of the form
(Re + Im i)
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
The Width and Places arguments have the same significance
that they do in the system procedure STR, and are applied
individually to both the REAL and IMAGINARY parts.
.
See Also:
CmpP2Str CmpP2StrD
unit ƒShƒCmplx
ƒCMPLXERROR
Declarations:
function CmplxError : integer;
.
Purpose:
Returns execution error conditions for the package.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
Return = 0 OK
-1 Attempt to divide by zero (CDiv)
-2 Magnitude of complex is zero (CpPwrR)
.
See Also:
unit ƒShƒCmplx
ƒCMPP2STR
Declarations:
function CmpP2Str(A : Complex; Width, Places : byte) :
string;
.
Purpose:
Converts a complex in polar form to a string with the angle
expressed in radians.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
The Width and Places arguments have the same significance
that they do in the system procedure STR, and are applied
individually to both the MAGNITUDE and ANGLE parts.
.
See Also:
Cmp2Str CmpP2StrD
unit ƒShƒCmplx
ƒCMPP2STRD
Declarations:
function CmpP2StrD(A : Complex; Width, Places : byte) :
string;
.
Purpose:
Converts a complex in polar form to a string with the angle
in degrees.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
The Width and Places arguments have the same significance
that they do in the system procedure STR, and are applied
individually to both the MAGNITUDE and ANGLE parts.
.
See Also:
Cmp2Str CmpP2Str
unit ƒShƒCmplx
ƒCMUL
Declarations:
procedure CMul(A, B : Complex; var Result : Complex);
function CMulF(A, B : Complex) : Complex;
.
Purpose:
Returns the product of two complex numbers A * B.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
.
See Also:
CAdd CDiv CSub RxC
unit ƒShƒCmplx
ƒCPPWRR
Declarations:
procedure CpPwrR(A : Complex; R : ComplexElement;
var Result : Complex);
function CpPwrRF(A : Complex; R : ComplexElement) : Complex;
.
Purpose:
Raises a complex (in polar form) to a real power.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
If A^.Re = 0, CmplxError will return -2, and
Result will be 0 + 0i
n.b. A^.Re contains the magnitude.
.
See Also:
unit ƒShƒCmplx
ƒCSUB
Declarations:
procedure CSub(A, B : Complex; var Result : Complex);
function CSubF(A, B : Complex) : Complex;
.
Purpose:
Returns the difference between two complex numbers A - B.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
.
See Also:
CAdd CDiv CMul
unit ƒShƒCmplx
ƒP2C
Declarations:
procedure P2C(A : Complex; var Result : Complex);
function P2CF(A : Complex) : Complex;
.
Purpose:
Transforms a complex in polar form into Cartesian form. The
magnitude is stored in A^.Re and the angle (expressed in radians)
in A^.Im.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
.
See Also:
C2P
unit ƒShƒCmplx
ƒRXC
Declarations:
procedure RxC(A : ComplexElement; B : Complex;
var Result : Complex);
function RxCF(A : ComplexElement; B : Complex) : Complex;
.
Purpose:
Returns the complex product of a real and a complex.
.
Examples:
See the file TESTCMPX.PAS
.
Comments:
This is simply a special case of CMul, in which the
imaginary part of one of the factors is zero. It occurrs with
sufficient frequency, however, to warrent separate treatment.
.
See Also:
CMul
unit ƒShƒCrcChk
ƒCRCCALC
Declarations:
function CrcCalc(FileName : String) : word;
.
Purpose:
To calculate the CRC16 of a named file, assumed to exist.
.
Examples:
if CrcCalc(MyFile) <> CrcShouldBe then begin
(*Take remedial action*)
end;
.
Comments:
MyFile is a file of any type, and may have any attributes
including Hidden, ReadOnly, etc. A run time error will result,
however, if the file does not exist.
unit ƒShƒCrcChk
ƒCRCCOPY
Declarations:
function CrcCopy(InFileName, OutFileName : String) : word;
.
Purpose:
Calculates the CRC16 value for file=InFileName, while
copying it to file=OutFileName.
.
Examples:
CrcShouldBe := CrcCopy(FileFromYou, MyFile);
if CrcCopy(MyFile, '') <> CrcShouldBe then begin
(*Take remedial action*)
end;
.
Comments:
The output file name is optional. If OutFileName is speci-
fied, InFileName is copied to OutFileName. If OutFileName is an
empty string, CrcCopy behaves exactly like CrcCalc. In either
case, the CRC16 value of InFileName is returned.
.
Using CrcCopy simply to calculate the CRC16 of the input
file will be marginally slower than using CrcCalc. In cases in
which both functionalities are required, however, using CrcCopy
exclusively will result in a somewhat smaller code segment.
unit ƒShƒDatPk
GregType = record
Year : LongInt;
Month,
Day : byte;
end;
Variables of this type contain a complete Gregorian date,
and are passed to many of the routines in this unit.
.
TimeType = record
H,
M,
S : byte;
end;
Variables of this type contain a complete time record, and
are passed to many of the routines in this unit.
unit ƒShƒDatPk
DayStr : array[0..6] of string[9] =
('Sunday' , 'Monday' , 'Tuesday' ,
'Wednesday', 'Thursday' , 'Friday' ,
'Saturday' );
unit ƒShƒDatPk
MonthStr: array[1..12] of string[9] =
('January' , 'February' , 'March',
'April' , 'May' , 'June',
'July' , 'August' , 'September',
'October' , 'November' , 'December');
unit ƒShƒDatPk
ƒDOW
Declarations:
function DoW(Greg : GregType) : byte;
.
Purpose:
To compute the day of the week (Sunday = 0; Saturday = 6)
from the Gregorian date.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒGREG2ANSI
Declarations:
function Greg2ANSI(G : GregType) : string;
.
Purpose:
Given a Gregorian date, return the date as an ANSI date
string (YYYYMMDD).
.
Examples:
See TESTDATE.PAS
.
Comments:
Note that the ANSI date format is both sortable and
readable.
.
See also:
JDN2ANSI
unit ƒShƒDatPk
ƒGREG2JDATE
Declarations:
function Greg2JDate(Greg : GregType) : integer;
.
Purpose:
To compute the Julian date from the Gregorian date.
.
Examples:
See TESTDATE.PAS
.
Comments:
Do not confuse the Julian date with the Julian Day-Number.
The Julian date, most commonly used in business applications, is
the serial index of a date WITHIN A GIVEN YEAR. The Julian Day-
Number is the serial index of a date from January 1, 4713 B.C.
.
See also:
JDate2Greg
unit ƒShƒDatPk
ƒGREG2JDN
Declarations:
function Greg2JDN(Greg : GregType) : LongInt;
.
Purpose:
To convert a Gregorian date into a Julian Day-Number.
.
Examples:
See TESTDATE.PAS
.
Comments:
The Julian Day-Number (JDN) is the basic form for date
manipulation within this unit. Thus this function performs the
primary conversion between dates in the customary form and
equivalent dates suitable for manipulation by ShDatPk.
.
See also:
JDN2Greg
unit ƒShƒDatPk
ƒJDATE2GREG
Declarations:
procedure JDate2Greg(JDate, Year : Integer;
var Greg : GregType);
.
Purpose:
To compute the Gregorian date from the Julian date.
.
Examples:
See TESTDATE.PAS
.
Comments:
Do not confuse the Julian date with the Julian Day-Number.
The Julian date, most commonly used in business applications, is
the serial index of a date WITHIN A GIVEN YEAR. The Julian Day-
Number is the serial index of a date from January 1, 4713 B.C.
.
See also:
Greg2JDate
unit ƒShƒDatPk
ƒJDN2ANSI
Declarations:
function JDN2ANSI(JDN : LongInt) : string;
.
Purpose:
Given a Julian Day-Number, return the JDN as an ANSI date
string (YYYYMMDD).
.
Examples:
See TESTDATE.PAS
.
Comments:
Note that the ANSI date format is both sortable and
readable.
.
See also:
Greg2ANSI
unit ƒShƒDatPk
ƒJDN2GREG
Declarations:
procedure JDN2Greg(JDN : LongInt; var Greg : GregType);
.
Purpose:
To compute the Gregorian date from the Julian Day-Number.
.
Examples:
See TESTDATE.PAS
.
Comments:
The Julian Day-Number (JDN) is the basic form for date
manipulation within this unit. Thus this function performs the
primary conversion between dates in ShDatPk internal form and
equivalent dates in the customary form.
.
See also:
Greg2JDN
unit ƒShƒDatPk
ƒGREG2STR
Declarations:
function Greg2Str(G : GregType; Delim : string) : string;
.
Purpose:
Returns a Gregorian date record as a string of the form
MMdDDdYYYY, where the separator, "d", is Delim[1].
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒJDN2STR
Declarations:
function JDN2Str(JDN : LongInt; Delim : string) : string;
.
Purpose:
Returns a Julian Day-Number as a string of the form
MMdDDdYYYY, where the separator, "d", is Delim[1].
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒNOW
Declarations:
function Now : LongInt;
.
Purpose:
Returns the system time as Seconds-Since-Midnight.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒNOW2TIME
Declarations:
procedure Now2Time(var T : TimeType);
.
Purpose:
Returns the system time as a Time record.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒNOWSTR
Declarations:
function NowStr(Delim : string; T24 : boolean) : string;
.
Purpose:
Returns the system time as a string of the form:
.
HHdMMdSSss if Delim is non-empty and T24 (24 hour time)
is false. The delimiter used, "d", is
Delim[1]. The suffix, "ss", is "am" or "pm" as
appropriate.
HHdMMdSS if Delim is non-empty and T24 (24 hour time)
is true. The delimiter used, "d", is Delim[1].
The time will be expressed in 24-hour form.
HHMMSSss if Delim is empty and T24 (24 hour time) is
false. The suffix, "ss", is "am" or "pm" as
appropriate.
HHMM if Delim is empty and T24 (24 hour time) is
true. The time will be expressed in 24-hour
form.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒSSM2TIME
Declarations:
procedure SSM2Time(SSM : LongInt; var T : TimeType);
.
Purpose:
Converts Seconds-Since-Midnight to a Time record.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒSSM2TIMESTR
Declarations:
function SSM2TimeStr(SSM : LongInt; Delim : string;
T24 : boolean) : string;
.
Purpose:
Converts Seconds-Since-Midnight to a time string, of the
form:
.
HHdMMdSSss if Delim is non-empty and T24 (24 hour time)
is false. The delimiter used, "d", is
Delim[1]. The suffix, "ss", is "am" or "pm" as
appropriate.
HHdMMdSS if Delim is non-empty and T24 (24 hour time)
is true. The delimiter used, "d", is Delim[1].
The time will be expressed in 24-hour form.
HHMMSSss if Delim is empty and T24 (24 hour time) is
false. The suffix, "ss", is "am" or "pm" as
appropriate.
HHMM if Delim is empty and T24 (24 hour time) is
true. The time will be expressed in 24-hour
form.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
TIME2SSM
Declaration
function Time2SSM(T : TimeType) : LongInt;
.
Purpose:
Converts a Time record to Seconds-Since-Midnight.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒTIME2TIMESTR
Declarations:
function Time2TimeStr(T : TimeType; Delim : string;
T24 : boolean) : string;
.
Purpose:
Converts a time record to a time string of the form:
.
HHdMMdSSss if Delim is non-empty and T24 (24 hour time)
is false. The delimiter used, "d", is
Delim[1]. The suffix, "ss", is "am" or "pm" as
appropriate.
HHdMMdSS if Delim is non-empty and T24 (24 hour time)
is true. The delimiter used, "d", is Delim[1].
The time will be expressed in 24-hour form.
HHMMSSss if Delim is empty and T24 (24 hour time) is
false. The suffix, "ss", is "am" or "pm" as
appropriate.
HHMM if Delim is empty and T24 (24 hour time) is
true. The time will be expressed in 24-hour
form.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒTODAY
Declarations:
function Today : LongInt;
.
Purpose:
Returns the system date as a Julian Day-Number.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒTODAY2ANSI
Declarations:
function Today2ANSI : string;
.
Purpose:
Returns the system date as an ANSI date string (YYYYMMDD).
.
Examples:
See TESTDATE.PAS
.
Comments:
Note that the ANSI date format is both sortable and
readable.
.
See also:
unit ƒShƒDatPk
ƒTODAY2GREG
Declarations:
procedure Today2Greg(var G : GregType);
.
Purpose:
Returns the system date as a Gregorian date record.
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒDatPk
ƒTODAYSTR
Declarations:
function TodayStr(Delim : string) : string;
.
Purpose:
Returns the system date as a string of the form MMdDDdYYYY,
where the separator, "d", is Delim[1].}
.
Examples:
See TESTDATE.PAS
.
Comments:
.
See also:
unit ƒShƒErrMsg
CHECKON
ƒCHECKOFF
Declarations:
procedure CheckOn;
procedure CheckOff;
.
Purpose:
Enables/disables the error reporting facilities of ShErrMsg.
.
Examples:
∙∙∙
CheckOff; {Turn off error reporting}
∙∙∙
CheckOn; {Turn error reporting back on}
.
Comments:
The default state following initialization is CheckOn.
unit ƒShƒErrMsg
ƒHALTMSG
Declarations:
procedure HaltMsg(Code : word; Msg : string);
.
Purpose:
To stop execution of the program, returning an error code to
DOS and optionally displaying a message.
.
Examples:
∙∙∙
HaltMsg(1000, 'Exiting on a problem in procedure FOO_BAZ');
.
Comments:
If Checking is ON, execution will stop with the message, and
a return code of 1000 will be passed to DOS.
.
ErrorLevel 1000
Exiting on a problem in procedure FOO_BAZ
.
If checking is OFF, execution will stop with no message, and
a return code of 1000 will be passed to DOS.
.
In either case, due to the way in which DOS is implemented,
an
.
IF ERRORLEVEL
.
command will be sensitive ONLY TO THE LOW BYTE of the code. Thus,
in the above example, DOS will see a return code of 232.
.
See also:
RunErrorMsg
unit ƒShƒErrMsg
ƒRUNERRORMSG
Declarations:
procedure RunErrorMsg(Code : integer; Msg : string);
.
Purpose:
To stop execution of the program with a runtime error
message, optionally augmented by an additional information
message, and returning an error code to DOS.
.
Examples:
∙∙∙
RunErrorMsg(1000, 'Problem in procedure FOO_BAZ');
.
Comments:
If Checking is ON, execution will stop with the following
message, and a return code of 1000 will be passed to DOS.
.
Runtime error 1000 at 0C8F:0008
Problem in procedure FOO_BAZ
.
If checking is OFF, execution will stop with the following
message, and a return code of 1000 will be passed to DOS.
.
Runtime error 232 at 0000:C8F8
.
In either case, due to the way in which DOS is implemented,
an
.
IF ERRORLEVEL
.
command will be sensitive ONLY TO THE LOW BYTE of the code. Thus,
in the above example, DOS will see a return code of 232.
.
Note also that, if checking if turned off, the error address
is not normalized.
.
See also:
HaltMsg
unit ƒShƒList
ƒslƒNodePtr = ^slNode;
ƒslƒNode = record
Data : pointer;
Next : slNodePtr;
end;
ƒdlƒNodePtr = ^dlNode;
ƒdlƒNode = record
Data : pointer;
Next,
Prev : dlNodePtr;
end;
These are the basic node structures of the nodes for singly
and doubly linked nodes. They will be of no particular interest
to you unless you need to modify the code of the unit.
unit ƒShƒList
ƒslƒList = record
DataRecSize : word;
Count : LongInt;
Head,
Tail,
Current : slNodePtr;
end;
ƒdlƒList = record
DataRecSize : word;
Count : LongInt;
Head,
Tail,
Current : dlNodePtr;
end;
These are the structures of the singly and doubly linked
lists, respectively. You will be passing a variable of one of
these types to almost all of the routines in the unit. The actual
details of the structure need not concern you, however, unless
you need to modify the code of the unit.
unit ƒShƒList
ƒdlƒLessFunc = function(var DataRec1, DataRec2) : boolean;
This is the form of a function which you will need to con-
struct if you are using the dlPutSorted routine. It is used to
determine the sort order of your data records. Its use is identi-
cal in concept to the "less" function of the TurboSort, TpSort,
or OpSort units.
unit ƒShƒList
ƒAPPEND
Declarations:
function ƒslAppend(var L : slList; var DataRec) : boolean;
function ƒdlAppend(var L : dlList; var DataRec) : boolean;
.
Purpose:
Appends a data record to an existing list. If the list is
empty, Append simply places the record in the list.
.
Comments:
The list must have been initialized prior to calling Append.
Append returns a value of "false" if insufficient heap space is
available for allocation of the node and data record.
.
Examples:
if not slAppend(MyList, MyDataRecord) then begin
{Execute your recovery code}
end;
.
See Also:
Put, PutPrev, PutSorted, Push
unit ƒShƒList
ƒCOUNT
Declarations:
function ƒslCount(L : slList) : LongInt;
function ƒdlCount(L : dlList) : LongInt;
.
Purpose:
Returns the number of items currently in the list.
.
Comments:
The item count is maintained continuously within the list
structure, so it is not necessary to scan the list in order to
generate the count.
.
Examples:
for T1 := 1 to slCount(MyList) do begin
if slPop(MyList, MyDataRec) then ;
(* Now process the record *)
end; {for T1 := ...}
.
This code will process each record in the list, and the list
will be left empty on loop exit.
unit ƒShƒList
ƒFREE
Declarations:
procedure ƒslFree(var L : slList);
procedure ƒdlFree(var L : dlList);
.
Purpose:
Releases the heap space allocated for a list and its data.
.
Comments:
This procedure should be called as soon as you have com-
pleted your operations on the specified list. The list must be
re-initialized if it is to be reused.
.
Examples:
slFree(MyList);
.
All heap space associated with "MyList" is released, follow-
ing which all the internal pointers of "MyList" are set to "nil"
and the associated data record length is set to zero.
.
See Also:
Init
unit ƒShƒList
ƒGETCURRENT
Declarations:
function ƒslGetCurrent(var L : slList;
var DataRec) : boolean;
function ƒdlGetCurrent(var L : dlList;
var DataRec) : boolean;
.
Purpose:
Returns the data record at the current node and does not
move the node pointer. Returns a function value of false if the
list is empty or the current node pointer is nil.
.
Comments:
This is essentially a "reread" operation. Normally, the cur-
rent node pointer will have been positioned during the course of
some other operation (e.g., GetFirst) and the data record will
have been returned as a result of that prior operation.
.
Examples:
if not slGetCurrent(MyList, MyDataRec) then begin
{Trying to read an empty list.}
end;
.
See Also:
GetFirst GetNext GetLast GetPrev
unit ƒShƒList
ƒGETFIRST
Declarations:
function ƒslGetFirst(var L : slList; var DataRec) : boolean;
function ƒdlGetFirst(var L : dlList; var DataRec) : boolean;
.
Purpose:
Returns the data record at the head of the list. Sets the
current node pointer to the head of the list. Returns a function
value of false if the list is empty.
.
Comments:
.
Examples:
if not slGetFirst(MyList, MyDataRec) then begin
{Trying to read an empty list.}
end;
.
See Also:
GetCurrent GetNext GetLast GetPrev
unit ƒShƒList
ƒGETLAST
Declarations:
function ƒslGetLast(var L : slList; var DataRec) : boolean;
function ƒdlGetLast(var L : dlList; var DataRec) : boolean;
.
Purpose:
Returns the data record at the tail of the list. Sets the
current node pointer to the tail of the list. Returns a function
value of false if the list is empty.
.
Comments:
.
Examples:
if not slGetLast(MyList, MyDataRec) then begin
{Trying to read an empty list.}
end;
.
See Also:
GetCurrent GetFirst GetNext GetPrev
unit ƒShƒList
ƒGETNEXT
Declarations:
function ƒslGetNext(var L : slList; var DataRec) : boolean;
function ƒdlGetNext(var L : dlList; var DataRec) : boolean;
.
Purpose:
Returns the next data record in the list. Sets the current
node pointer to the record retrieved. Returns a function value of
false if the list is empty or if the last record successfully
retrieved was at the list tail. In this latter case, calling
slGetNext or dlGetNext again will retrieve the head of the list.
.
Comments:
.
Examples:
{The following example assumes boolean short-circuiting ($B+)}
if (not slGetNext(MyList, MyDataRec))
{slGetNext false means an empty list or end of list}
and slGetNext(MyList, MyDataRec) then begin
{processing the head of the list}
end
else begin
{processing the normal "next" element in the list}
end;
.
See Also:
GetCurrent GetFirst GetLast GetPrev
unit ƒShƒList
ƒGETPREV
Declarations:
function ƒdlGetPrev(var L : dlList; var DataRec) : boolean;
.
Purpose:
Same as dlGetNext, but in the opposite direction. Returns
the previous data record in the list. Sets the current node
pointer to the record retrieved. Returns a function value of
false if the list is empty or if the last record successfully
retrieved was at the list head. In this latter case, calling
dlGetPrev again will retrieve the tail of the list.
.
Comments:
Note that the GetPrev operation can only be performed on
doubly linked lists. There is no equivalent operation for singly
linked lists.
.
Examples:
{The following example assumes boolean short-circuiting ($B+)}
if (not dlGetPrev(MyList, MyDataRec))
{dlGetPrev false means an empty list or top of list}
and dlGetPrev(MyList, MyDataRec) then begin
{processing the tail of the list}
end
else begin
{processing the normal "prior" element in the list}
end;
.
See Also:
GetCurrent GetFirst GetLast GetNext
unit ƒShƒList
ƒLISTINIT
Declarations:
procedure ƒslListInit(var L : slList; RecSize : word);
procedure ƒdlListInit(var L : dlList; RecSize : word);
.
Purpose:
Initializes a singly or doubly linked list, as appropriate.
.
Comments:
The list initialization routines initialize only the vari-
ables of type slList or dlList. They perform no memory alloca-
tion. Memory allocation is performed only by the various PUT
routines.
.
The ListInit routines **must** be called before any attempt
is made to place any data in, or retrieve any data from any
LIST-type variable. Also, once an initialized list has received
data, ListInit **must not** be called prior to a call to Free.
Failure to observe either of these warnings will produce
unpredictable but probably disastrous results.
.
Examples:
slListInit(MyList);
.
See Also:
Free
unit ƒShƒList
ƒPOP
Declarations:
function ƒslPop(var L : slList; var DataRec) : boolean;
function ƒdlPop(var L : dlList; var DataRec) : boolean;
.
Purpose:
Returns the data record at the head of the list, then deal-
locates the space associated with the data record and node. Re-
turns a function value of false if the list is empty.
.
Comments:
.
Examples:
while slPop(MyList, MyDataRec) do begin
{process the retrieved record}
end;
.
This code will retrieve each record on the list and free up
the space associated with each, as it is retrieved. You will end
up with an empty list.
.
See Also:
Push Free
unit ƒShƒList
ƒPUSH
Declarations:
function ƒslPush(var L : slList; var DataRec) : boolean;
function ƒdlPush(var L : dlList; var DataRec) : boolean;
.
Purpose:
Pushes a data record onto the top of the list. Returns a
function value of false if there is insufficient heap space to
accommodate the list node and data record.
.
Comments:
.
Examples:
if not slPush(MyList, MyDataRec) then begin
{perform recovery operations}
end;
.
See Also:
Append Put PutPrev PutSorted Pop
unit ƒShƒList
ƒPUT
Declarations:
function ƒslPut(var L : slList; var DataRec) : boolean;
function ƒdlPut(var L : dlList; var DataRec) : boolean;
.
Purpose:
Inserts a data record following the current node; returns
with current pointer directed to the new node. Returns a function
value of false if there is insufficient heap space to accommodate
the list node and data record.
.
Comments:
.
Examples:
if not slPut(MyList, MyDataRec) then begin
{perform recovery operations}
end;
.
See Also:
Append Push PutPrev PutSorted Pop
unit ƒShƒList
ƒPUTPREV
Declarations:
function ƒdlPutPrev(var L : dlList; var DataRec) : boolean;
.
Purpose:
Inserts a data record ahead of the current node; returns
with current pointer directed to the new node. Returns a function
value of false if there is insufficient heap space to accommodate
the list node and data record.
.
Comments:
Note that the PutPrev operation can only be performed on
doubly linked lists. There is no equivalent operation for singly
linked lists.
.
Examples:
if not dlPutPrev(MyList, MyDataRec) then begin
{perform recovery operations}
end;
.
See Also:
Append GetPrev Push Put PutSorted
unit ƒShƒList
ƒPUTSORTED
Declarations:
function ƒdlPutSorted(var L : dlList; var DataRec;
Less : dlLessFunc) : boolean;
.
Purpose:
Inserts a data record into the list in sorted order, as
determined by the user-defined boolean function LESS. Returns a
function value of false if there is insufficient heap space to
accommodate the list node and data record.
.
Comments:
The function LESS is a user-defined boolean function whose
declaration **must** be of the form
.
function Less(var Rec1, Rec2) :boolean;
.
and **must** be compiled under the FAR model.
.
Note that the PutSorted operation can only be performed on
doubly linked lists. There is no equivalent operation for singly
linked lists.
.
Note also that, to build the sorted list in descending order
rather than ascending, it is only necessary to reverse the sense
of the inequality in the comparison function.
.
Examples:
{$F+}
function MyLess(var MyRec1, MyRec2) : boolean;
begin
MyLess := (MyRecType(MyRec1).FieldA <
MyRecType(MyRec2).FieldA);
end;
{$F-}
...
if not dlPutSorted(MyList, MyDataRec, @MyLess) then begin
{do something}
end;
Incorrect!!! The @-symbol cannot be used here.
.
if not dlPutSorted(MyList, MyDataRec, MyLess) then begin
{do something}
end;
Correct. Only the function name is passed.
.
See Also:
Append GetPrev Push Put PutPrev
unit ƒShƒList
ƒSPACEUSED
Declarations:
function ƒslSpaceUsed(L : slList) : LongInt;
function ƒdlSpaceUsed(L : dlList) : LongInt;
.
Purpose:
Returns the total amount of heap space currently allocated
to the list and its data.
.
Comments:
.
Examples:
WriteLn(slSpaceUsed(MyList), ' total bytes used');
.
See Also:
Count
unit ƒShƒLngStr
ƒLongStringType = record
Length, {Dynamic length}
dLength : word; {"Declared" length}
lsData : array[1..1] of char;
end;
The record structure allocated on the heap for the storage
of LongString data.
.
ƒLongString = ^LongStringType;
The type expected as actual parameters to the routines in
this unit; also, the type returned by most of the functions.
.
ƒlsCompType = (Less, Equal, Greater);
The type returned by the LongString comparison functions.
.
ƒlsDelimSetType = set of char;
The type of the set of characters which the GetNext routines
will use as word delimiters.
.
ƒRingSize : byte = 25;
The number of elements in the ring buffer, used to store
pointers returned by function calls of type LongString. This
value may be freely increased to a maximum value of 100 during
program execution, if necessary. Decreasing it, however, could
result in orphan blocks allocated on the heap, with no way to
recover them.
.
ƒlsDelimSet : lsDelimSetType = [#0..#32];
The typed constant used by the GetNext routines to determine
the end of a substring to be returned. It may be freely changed
during program execution.
.
ƒMaxLongString = 65517;
The maximum length of a LongString.
.
ƒNotFound = 0;
Returned by the lsPos functions if a substring is not found.
unit ƒShƒLngStr
ƒlsCENTER
Declarations:
procedure lsCenter
(A: LongString; Width: word; B: LongString);
function ƒlsƒCenterF
(A: LongString; Width: word): LongString;
.
Purpose:
Return a LongString centered in a LongString of blanks with
specified width.
.
Examples:
If A contains "abcdefg"
then lsCenter(A, 13, B);
results in B containing " abcdefg "
.
Comments:
If the length of A already exceeds Width, A will be returned
unchanged.
.
See Also:
lsCenterCh
unit ƒShƒLngStr
ƒlsCENTERCH
Declarations:
procedure lsCenterCh
(A: LongString; Ch: Char; Width: word; B: LongString);
function ƒlsƒCenterChF
(A: LongString; Ch: Char; Width: word): LongString;
.
Purpose:
Return a LongString centered in a LongString of Ch with spe-
cified width.
.
Examples:
If A contains "abcdefg"
then lsCenterCh(A, '+', 13, B);
results in B containing "+++abcdefg+++"
.
Comments:
If the length of A already exceeds Width, A will be returned
unchanged.
.
See Also:
lsCenter
unit ƒShƒLngStr
ƒlsCHARSTR
Declarations:
procedure lsCharStr
(Ch: Char; Len: word; A: LongString);
function ƒlsƒCharStrF
(Ch: Char; Len: word): LongString;
.
Purpose:
Return a LongString of length Len filled with Ch.
.
Examples:
The call lsCharStr('+', 10, A);
results in A containing "++++++++++"
.
Comments:
If Len is greater than the maximum length of A, the returned
LongString will be equal in length to the maximum length of A.
.
See Also:
unit ƒShƒLngStr
ƒlsCOMP
Declarations:
function lsƒComp
(A1, A2: LongString): lsCompType;
.
Purpose:
Compares A1 to A2, returning LESS, EQUAL, or GREATER.
.
Examples:
For a normal COMPARE,
case lsComp(LS1, LS2) of
LESS : {Do This}
EQUAL : {Do That}
GREATER : {Do The Other}
end; {case lsComp}
.
For a case-insensitive COMPARE,
case lsComp(lsUpcaseF(LS1), lsUpcaseF(LS2)) of
LESS : {Do This}
EQUAL : {Do That}
GREATER : {Do The Other}
end; {case lsComp}
.
Comments:
This function completely implements the analog of the string
comparison operators of Turbo Pascal.
.
See Also:
unit ƒShƒLngStr
ƒlsCONCAT
Declarations:
procedure lsConcat
(A, B, C: LongString);
function ƒlsƒConcatF
(A, B: LongString): LongString;
procedure lsConcatLs2Str
(S: string; A: LongString; C: LongString);
function ƒlsƒConcatLs2StrF
(S: string; A: LongString): LongString;
procedure lsConcatStr2Ls
(A: LongString; S: string; C: LongString);
function ƒlsƒConcatStr2LsF
(A: LongString; S: string): LongString;
.
Purpose:
Concatenate the second parameter to the end of the first.
.
Examples:
If A contains "abcdefg"
and B contains "hijklmn"
then lsConcat(A, B, C);
results in C containing "abcdefghijklmn"
.
Comments:
.
See Also:
unit ƒShƒLngStr
ƒlsCOPY
Declarations:
procedure lsCopy
(A: LongString; Start, Len: word; B: LongString);
function ƒlsƒCopyF
(A: LongString; Start, Len: word): LongString;
.
Purpose:
Return a LongString substring of A. The substring begins at
position Start of A and will be of length Len.
.
Examples:
If A contains "abcdefg"
then lsCopy(A, 4, 3, B);
results in B containing "def"
.
If A contains "abcdefg"
then lsCopy(A, 4, 10, B);
results in B containing "defg"
.
Comments:
Start=1 for first char in A.
If Start > lsLength(A), an empty LongString will be
returned.
.
If Start+Len exceeds the length of A, the returned
LongString will be of length lsLength(A)-Start+1.
.
See Also:
unit ƒShƒLngStr
ƒlsCOUNT
Declarations:
function lsƒCount
(A, Obj: LongString): word;
function ƒlsƒCountStr
(A: LongString; Obj: string): word;
function ƒlsƒCountStrUC
(A: LongString; Obj: string): word;
function ƒlsƒCountUC
(A, Obj: LongString): word;
.
Purpose:
Returns the total number of non-overlapping occurrences of
Obj in A.
.
Examples:
if lsCountStrUC(MyLS, 'abc') <> NotFound then {Do something}
.
If A contains "abcdeabcdeabcde"
and Obj contains "BCD"
then lsCount(A, Obj)
returns NotFound ( = 0 )
but lsCountUC(A, Obj)
returns 3
.
Comments:
If Obj is not a substring of A, returns NotFound (i.e., 0).
.
See Also:
unit ƒShƒLngStr
ƒlsDELALL
Declarations:
procedure lsDelAll
(A, Obj, B: LongString);
function ƒlsƒDelAllF
(A, Obj: LongString): LongString;
procedure lsDelAllStr
(A: LongString; Obj: string; B: LongString);
function ƒlsƒDelAllStrF
(A: LongString; Obj: string): LongString;
procedure lsDelAllStrUC
(A: LongString; Obj: string; B: LongString);
function ƒlsƒDelAllStrUCF
(A: LongString; Obj: string): LongString;
procedure lsDelAllUC
(A, Obj, B: LongString);
function ƒlsƒDelAllUCF
(A, Obj: LongString): LongString;
.
Purpose:
Deletes all occurrences of Obj in A.
.
Examples:
See below.
.
Comments:
Should the deletion of Obj from A result in a new occurrence
of Obj in A, the new occurrence will not be deleted, e.g.,
.
If A contains 'aabcbcabcd'
and Obj contains 'abc'
then lsDelAll(A, Obj, B);
results in B containing 'abcd'
and not 'd'
.
To delete all occurrences including such incidental
occurrences, one would use, e.g.,
.
repeat
lsDelAll(A, Obj, A);
until lsCount(A, Obj) = 0;
.
See Also:
lsRepAll lsCount
unit ƒShƒLngStr
ƒlsDELETE
Declarations:
procedure lsDelete
(A: LongString; Start, Len: word; B: LongString);
function ƒlsƒDeleteF
(A: LongString; Start, Len: word): LongString;
.
Purpose:
Delete Len characters of A, starting at position Start.
.
Examples:
If A contains "abcdefg"
then lsDelete(A, 4, 3, B);
results in B containing "abcg"
.
If A contains "abcdefg"
then lsDelete(A, 4, 10, B);
results in B containing "abc"
.
Comments:
If Start is greater than the length of A, B = A on output.
.
See Also:
lsDelAll lsRepAll
unit ƒShƒLngStr
ƒlsDISPOSE
Declarations:
procedure lsDispose
(var A: LongString);
.
Purpose:
Dispose of A, releasing its heap space.
.
Examples:
The call lsDispose(A);
results in All heap space associated with A is released
and A = nil
.
Comments:
.
See Also:
lsInit
unit ƒShƒLngStr
ƒlsGETNEXT
Declarations:
procedure lsGetNext
(LS1, LS2: LongString);
function ƒlsƒGetNextF
(LS1: LongString): LongString;
procedure lsGetNextStr
(LS1: LongString; var S2: string);
function ƒlsƒGetNextStrF
(LS1: LongString): string;
.
Purpose:
Returns the next substring of LS1 which is delimited by a
member of lsDelimSet.
.
Examples:
If A contains "abc def ghi jkl"
then the two calls
lsGetNext(A, B);
lsGetNext(A, B);
result in A containing " ghi jkl"
and B containing "def"
.
Comments:
On return, LS1 is returned untrimmed, but with the first
matching substring deleted.
.
See Also:
unit ƒShƒLngStr
ƒlsINIT
Declarations:
function lsƒInit
(var A: LongString; L: word): boolean;
.
Purpose:
"Declares" a LongString of maximum declared length L and
establishes space for it on the heap.
.
Examples:
The call if lsInit(A, 750) then {Do something};
results in a. A returned function value of "true"
b. 754 bytes being allocated on the heap.
(750 bytes for the character string,
4 overhead bytes.)
c. A containing a pointer to the heap space.
.
The call lsInit(A, 65518); {MaxLongString = 65517}
results in a. A returned function value of "false"
b. No space allocation on the heap.
c. A = nil
.
Comments:
Returns false if L is greater than MaxLongString.
.
If there is insufficient heap space to accommodate the
LongString, the program will terminate with a run-time error of
250 (if lsInit has been called directly) or 251 (if lsInit has
been called while attempting to allocate space on the ring
buffer.
.
See Also:
lsDispose
unit ƒShƒLngStr
ƒlsIOFF
Declarations:
procedure lsIoff;
.
Purpose:
Turns I/O checking off during execution of lsReadLn and
lsWriteLn.
.
Examples:
lsIoff;
lsReadLn(MyFile, MyLS);
if lsIoResult <> 0 then {Do something}
lsIon;
.
Comments:
lsIoff, lsIon, and lsIoResult MUST be used for LongString
I/O operations in place of $I-, $I+, and IoResult.
.
Emulates at execution time the action of the $I- compiler
directive, but only for LongString I/O. The default state is
"on".
.
If I/O checking is off lsIoResult MUST be called after each
call to lsReadLn or lsWriteLn. If I/O checking is on, and if an
I/O error occurs, the program will terminate with a run-time
error. This action duplicates the action of the IoResult function
for normal I/O.
.
See Also:
lsIon lsIoResult
unit ƒShƒLngStr
ƒlsION
Declarations:
procedure lsIon;
.
Purpose:
Turns I/O checking on during execution of lsReadLn and
lsWriteLn.
.
Examples:
lsIoff;
lsReadLn(MyFile, MyLS);
if lsIoResult <> 0 then {Do something}
lsIon;
.
Comments:
lsIoff, lsIon, and lsIoResult MUST be used for LongString
I/O operations in place of $I-, $I+, and IoResult.
.
Emulates at execution time the action of the $I+ compiler
directive, but only for LongString I/O. The default state is
"on".
.
If I/O checking is off lsIoResult MUST be called after each
call to lsReadLn or lsWriteLn. If I/O checking is on, and if an
I/O error occurs, the program will terminate with a run-time
error. This action duplicates the action of the IoResult function
for normal I/O.
.
See Also:
lsIoff lsIoResult
unit ƒShƒLngStr
ƒlsIORESULT
Declarations:
function lsƒIoResult: word;
.
Purpose:
Returns the IoResult of the last lsReadLn or lsWriteLn
performed, and clears the internal variable used to store the
value.
.
Examples:
lsIoff;
lsReadLn(MyFile, MyLS);
if lsIoResult <> 0 then {Do something}
lsIon;
.
Comments:
lsIoff, lsIon, and lsIoResult MUST be used for LongString
I/O operations in place of $I-, $I+, and IoResult.
.
If I/O checking is off lsIoResult MUST be called after each
call to lsReadLn or lsWriteLn. If I/O checking is on, and if an
I/O error occurs, the program will terminate with a run-time
error. This action duplicates the action of the IoResult function
for normal I/O.
.
See Also:
lsIoff lsIon
unit ƒShƒLngStr
ƒlsINSERT
Declarations:
procedure lsInsert
(A, Obj: LongString; Start: word; B: LongString);
function ƒlsƒInsertF
(A, Obj: LongString; Start: word): LongString;
procedure lsInsertStr
(A: LongString; Obj: string; Start: word;
B: LongString);
function ƒlsƒInsertStrF
(A: LongString; Obj: string; Start: word): LongString;
.
Purpose:
Insert Obj into A at position Start returning a new
LongString.
.
Examples:
If A contains "abcdef"
and Obj contains "ABC"
then lsInsert(A, Obj, 4, B);
results in B containing "abcABCdef"
.
Comments:
If Start > lsLength(A), no action is taken.
.
See Also:
lsDelete
unit ƒShƒLngStr
ƒlsLEFTPAD
Declarations:
procedure lsLeftPad
(A: LongString; Len: word; B: LongString);
function ƒlsƒLeftPadF
(A: LongString; Len: word): LongString;
.
Purpose:
Left-pad the LongString in A to length Len with blanks,
returning a new LongString.
.
Examples:
If A contains "abc"
then lsLeftPad(A, 5, B);
results in B containing " abc"
.
Comments:
If Len < lsLength(A), A is returned truncated without
padding.
.
See Also:
lsLeftPadCh lsPad lsPadCh
unit ƒShƒLngStr
ƒlsLEFTPADCH
Declarations:
procedure lsLeftPadCh
(A: LongString; Ch: Char; Len: word; B: LongString);
function ƒlsƒLeftPadChF
(A: LongString; Ch: Char; Len: word): LongString;
.
Purpose:
Left-pad the LongString in A to length Len with Ch,
returning a new LongString.
.
Examples:
If A contains "abc"
then lsLeftPad(A, '+', 5, B);
results in B containing "++abc"
.
Comments:
.
See Also:
lsLeftPad lsPad lsPadCh
unit ƒShƒLngStr
ƒlsLENGTH
Declarations:
function lsƒLength
(A: LongString): word;
.
Purpose:
Return the length of a LongString. A must have been
initialized.
.
Examples:
If A contains "Cogito, ergo sum."
then lsLength(A)
returns 17
.
Comments:
.
See Also:
unit ƒShƒLngStr
ƒlsLOCASE
Declarations:
procedure lsLocase
(A, B: LongString);
function ƒlsƒLocaseF
(A: LongString): LongString;
.
Purpose:
Locase the LongString in A, returning a new LongString.
.
Examples:
If A contains "ABCdefGHIjkl"
then lsLocase(A, B);
results in B containing "abcdefghijkl"
.
Comments:
.
See Also:
lsUpcase
unit ƒShƒLngStr
ƒlsLONGSTRING2STR
Declarations:
function lsƒLongString2Str
(A: LongString): string;
.
Purpose:
Convert a LongString to a Turbo string.
.
Examples:
If A (LongString) contains "abcdef"
then lsLongString2Str(A)
returns 'abcdef' (string)
.
Comments:
If lsLength(A) > 255, the returned string will be truncated
to length 255.
.
See Also:
lsStr2LongString
unit ƒShƒLngStr
ƒlsPAD
Declarations:
procedure lsPad
(A: LongString; Len: word; B: LongString);
function ƒlsƒPadF
(A: LongString; Len: word): LongString;
.
Purpose:
Right-pad the LongString in A to length Len with blanks,
returning a new LongString.
.
Examples:
If A contains "abc"
then lsPad(A, 5, B);
results in B containing "abc "
.
but if lsInit(C, 5) = true
then lsPad(A, 8, C);
also results in C containing "abc "
.
Comments:
.
See Also:
lsPadCh lsLeftPad lsLeftPadCh
unit ƒShƒLngStr
ƒlsPADCH
Declarations:
procedure lsPadCh
(A: LongString; Ch: Char; Len: word; B: LongString);
function ƒlsƒPadChF
(A: LongString; Ch: Char; Len: word): LongString;
.
Purpose:
Right-pad the LongString in A to length Len with Ch,
returning a new LongString.
.
Examples:
If A contains "abc"
then lsPadCh(A, '+', 5, B);
results in B containing "abc++"
.
but if lsInit(C, 5) = true
then lsPadCh(A, '+', 8, C);
also results in C containing "abc++"
.
Comments:
.
See Also:
lsPad lsLeftPad lsLeftPadCh
unit ƒShƒLngStr
ƒlsPOS
Declarations:
function lsƒPos
(Obj, A: LongString): word;
function ƒlsƒPosStr
(Obj: string; A: LongString): word;
function ƒlsƒPosUC
(Obj, A: LongString): word;
function ƒlsƒPosStrUC
(Obj: string; A: LongString): word;
.
Purpose:
Return the position of Obj in A, returning NotFound if not
found.
.
Examples:
If A contains "abcdeabcdeabcde"
and Obj contains "BCD"
then lsPos(A, Obj)
returns NotFound ( = 0 )
but lsPosUC(A, Obj)
returns 2
.
Comments:
.
See Also:
unit ƒShƒLngStr
ƒlsPOSSET
Declarations:
function lsƒPosSet(A : CharSet; S : LongString) : byte;
.
Purpose:
Returns the position of the first occurrence of any member
of A in S.
.
Comments:
This function is primarily intended for internal use.
.
Examples:
If S = 'X1Y2C3Z4B'
and A = ['A','B','C']
then lsPosSet(A, S) will return 5.
.
See also:
unit ƒShƒLngStr
ƒlsREADLN
Declarations:
procedure lsReadLn
(var F: Text; A: LongString);
.
Purpose:
Read a LongString from a text file.
.
Examples:
lsReadLn(MyFile, A);
.
Comments:
If the "declared" length of A (set by lsInit) is less than
the actual length of the line in the text file, the incoming
string will be truncated to the "declared" length of A and the
file will be positioned at the beginning of the next line (the
exact analog of a normal Turbo PASCAL string ReadLn).
If I/O checking is off lsIoResult MUST be called after each
call to lsReadLn or lsWriteLn. If I/O checking is on, and if an
I/O error occurs, the program will terminate with a run-time
error. This action duplicates the action of the IoResult function
for normal I/O.
.
See Also:
lsIoff lsIon lsIoResult lsWriteLn
unit ƒShƒLngStr
ƒlsREPALL
Declarations:
procedure lsRepAll
(A, Obj, Obj1, B: LongString);
function ƒlsƒRepAllF
(A, Obj, Obj1: LongString): LongString;
procedure lsRepAllStr
(A: LongString; Obj, Obj1: string; B: LongString);
function ƒlsƒRepAllStrF
(A: LongString; Obj, Obj1: string): LongString;
procedure lsRepAllStrUC
(A: LongString; Obj, Obj1: string; B: LongString);
function ƒlsƒRepAllStrUCF
(A: LongString; Obj, Obj1: string): LongString;
procedure lsRepAllUC
(A, Obj, Obj1, B: LongString);
function ƒlsƒRepAllUCF
(A, Obj, Obj1: LongString): LongString;
.
Purpose:
Replaces all occurrences of Obj in A with Obj1.
.
Examples:
If A contains 'aabcbcabcd'
and Obj contains 'abc'
and Obj1 contains '12345'
then lsRepAll(A, Obj, Obj1, B);
results in B containing 'a12345bc12345d'
.
Comments:
Should the replacement of Obj by Obj1 in A result in a new
occurrence of Obj in A, the new occurrence will not be replaced.
To do so, except under rather unusual conditions, could result in
a non-terminating condition.
.
See Also:
lsDelAll
unit ƒShƒLngStr
ƒlsSIZEOF
Declarations:
function lsƒSizeOf
(A: LongString): word;
.
Purpose:
Returns the total heap space required for A, including the
two control words. A must have been initialized.
.
Examples:
See below.
.
Comments:
lsSizeOf MUST be used to determine the effective size of a
LongString. Any attempt to use SizeOf(A) will return a value of
4; any attempt to use SizeOf(A^) will return a value of 5.
Neither is particularly informative!
.
Remember that, just as
SizeOf(StringVariable)
returns a value one greater than the declared length of
StringVariable, so
lsSizeOf(LongStringVariable)
will return a value four greater than the "declared" length of
LongStringVariable.
.
If A has not been initialized, the results are
unpredictable.
.
See Also:
lsLength
unit ƒShƒLngStr
ƒlsSTR2LONGSTRING
Declarations:
procedure lsStr2LongString
(S: string; A: LongString);
function ƒlsƒStr2LongStringF
(S: string): LongString;
.
Purpose:
Convert a Turbo string into a LongString.
.
Examples:
If S (string) contains "abcdef"
then lsStr2LongString(S, A);
results in A (LongString) containing "abcdef"
.
Comments:
.
See Also:
lsLongString2Str
unit ƒShƒLngStr
ƒlsTRANSFER
Declarations:
procedure lsTransfer
(A, B: LongString);
.
Purpose:
Transfers the contents of A into B.
.
Examples:
B^ := A^;
INCORRECT!! This construct will give unpredictable but guar-
anteed incorrect results.
.
lsTransfer(A, B);
Correct. ALWAYS use lsTransfer to move the contents of one
LongString into another.
.
Comments:
.
See Also:
unit ƒShƒLngStr
ƒlsTRIM
Declarations:
procedure lsTrim
(A, B: LongString);
function ƒlsƒTrimF
(A: LongString): LongString;
.
Purpose:
Return a LongString with leading and trailing white space
removed.
.
Examples:
If A contains " Cogito, ergo sum. "
then lsTrim(A, B);
results in B containing "Cogito, ergo sum."
.
Comments:
"White space" is any sequence of characters in the range
#0..#32.
.
See Also:
lsTrimLead lsTrimTrail
lsTrimLeadSet lsTrimSet lsTrimTrailSet
unit ƒShƒLngStr
ƒlsTRIMLEAD
Declarations:
procedure lsTrimLead
(A, B: LongString);
function ƒlsƒTrimLeadF
(A: LongString): LongString;
.
Purpose:
Return a LongString with leading white space removed.
.
Examples:
If A contains " Cogito, ergo sum. "
then lsTrimLead(A, B);
results in B containing "Cogito, ergo sum. "
.
Comments:
"White space" is any sequence of characters in the range
#0..#32.
.
See Also:
lsTrim lsTrimTrail
lsTrimLeadSet lsTrimSet lsTrimTrailSet
unit ƒShƒLngStr
ƒlsTRIMTRAIL
Declarations:
procedure lsTrimTrail
(A, B: LongString);
function ƒlsƒTrimTrailF
(A: LongString): LongString;
.
Purpose:
Return a LongString with trailing white space removed.
.
Examples:
If A contains " Cogito, ergo sum. "
then lsTrimTrail(A, B);
results in B containing " Cogito, ergo sum."
.
Comments:
"White space" is any sequence of characters in the range
#0..#32.
.
See Also:
lsTrim lsTrimLead
lsTrimLeadSet lsTrimSet lsTrimTrailSet
unit ƒShƒLngStr
ƒlsTRIMLEADSET
Declarations:
procedure lsTrimLeadSet
(A : LongString; CS : CharSet; B : LongString);
function ƒlsƒTrimLeadSetF
(A : LongString; CS : CharSet) : LongString;
.
Purpose:
Returns a LongString with leading characters in CS stripped.
.
Examples:
See the file TESTLSTR.PAS
.
Comments:
CS contains an arbitrary set of characters.
.
See also:
lsTrimSet lsTrimTrailSet
lsTrim lsTrimLead lsTrimTrail
unit ƒShƒLngStr
ƒlsTRIMSET
Declarations:
procedure lsTrimSet
(A : LongString; CS : CharSet; B : LongString);
function ƒlsƒTrimSetF
(A : LongString; CS : CharSet) : LongString;
.
Purpose:
Returns a LongString with leading and trailing characters in
CS stripped.
.
Examples:
See the file TESTLSTR.PAS
.
Comments:
CS contains an arbitrary set of characters.
.
See also:
lsTrimLeadSet lsTrimTrailSet
lsTrim lsTrimLead lsTrimTrail
unit ƒShƒLngStr
ƒlsTRIMTRAILSET
Declarations:
procedure lsTrimTrailSet
(A : LongString; CS : CharSet; B : LongString);
function ƒlsƒTrimTrailSetF
(A : LongString; CS : CharSet) : LongString;
.
Purpose:
Returns a LongString with trailing characters in CS
stripped.
.
Examples:
See the file TESTLSTR.PAS
.
Comments:
CS contains an arbitrary set of characters.
.
See also:
lsTrimLeadSet lsTrimSet
lsTrim lsTrimLead lsTrimTrail
unit ƒShƒLngStr
ƒlsUPCASE
Declarations:
procedure lsUpcase
(A, B: LongString);
function ƒlsƒUpcaseF
(A: LongString): LongString;
.
Purpose:
Upcase the LongString in A, returning a new LongString.
.
Examples:
If A contains "ABCdefGHIjkl"
then lsUpcase(A, B);
results in B containing "ABCDEFGHIJKL"
.
Comments:
.
See Also:
lsLocase
unit ƒShƒLngStr
ƒlsWRITELN
Declarations:
procedure lsWriteLn
(var F: Text; A: LongString);
.
Purpose:
Write a LongString to a text file.
.
Examples:
lsWriteLn(MyFile, A);
.
Comments:
If I/O checking is off lsIoResult MUST be called after each
call to lsReadLn or lsWriteLn. If I/O checking is on, and if an
I/O error occurs, the program will terminate with a run-time
error. This action duplicates the action of the IoResult function
for normal I/O.
.
See Also:
lsIoff lsIon lsIoResult lsReadLn
unit ƒShƒUtilPk
ƒDelimSetType = Set of Char;
.
ƒDelimSet : DelimSetType = [#0..#32];
The typed constant used by the GetNext routines to determine
the end of a substring to be returned. It may be freely changed
during program execution.
unit ƒShƒUtilPk
ƒStartingMode : Integer;
{Initial video mode of the system (Mono, CO80, BW40, ...)}
.
ƒStartingAttr : Byte;
{Initial video attribute of the system}
unit ƒShƒUtilPk
ƒBETWS
Declarations:
function BetwS(Lower, Item, Upper : LongInt) : boolean;
.
Purpose:
Performs a SIGNED test of the condition that
.
Lower <= Item <= Upper
.
returning TRUE if and only if the condition is met.
.
Comments:
Lower, Item, and Upper can be any combination of 1, 2, and
4-byte entities.
.
Note that
BetwU($EA, $EA, $FA) = true
whereas
BetwS($EA, $EA, $FA) = false
.
Examples:
See TESTBETW.PAS
.
See also:
BetwU
unit ƒShƒUtilPk
ƒBETWU
Declarations:
function BetwU(Lower, Item, Upper : LongInt) : boolean;
.
Purpose:
Performs an UNSIGNED test of the condition that
.
Lower <= Item <= Upper
.
returning TRUE if and only if the condition is met.
.
Comments:
Lower, Item, and Upper can be any combination of 1, 2, and
4-byte entities.
.
Note that
BetwU($EA, $EA, $FA) = true
whereas
BetwS($EA, $EA, $FA) = false
.
Examples:
See TESTBETW.PAS
.
See also:
BetwS
unit ƒShƒUtilPk
ƒDELALL
Declarations:
procedure DelAll(S1, DS : String; S2);
function ƒDelAllF(S1, DS : string) : string;
.
Purpose:
In string S1 delete all occurrences of DS.
.
Comments:
.
Examples:
See the file TESTUTIL.PAS
.
See also:
RepAll
unit ƒShƒUtilPk
ƒGETNEXT
Declarations:
procedure GetNext(var S1, S2 : String);
function ƒGetNextF(var S1 : String) : String;
.
Purpose:
Returns the next leading substring of S1 which is delimited
by a member of DelimSet.
.
Comments:
S1 is returned with the sub-string stripped off, but not
trimmed. S2 or the function value is trimmed.
.
If S1 is empty on entry, both S1 and S2 (or the function
value) will be empty on return.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒHEX
Declarations:
function HEX(A : LongInt) : String;
.
Purpose:
Converts any INTEGER-type variable into a string
correspnoding to the hex value.
.
Comments:
The parameter A may be of any Integer type (ShortInt, Byte,
Integer, Word, or LongInt
.
HEX will return either a 2, 4, or 8 character string,
depending on whether the actual value of the parameter (rather
than its type) is representable by a
.
1 byte value (ShortInt, Byte)
2 byte value (Integer, Word)
4 byte value (LongInt)
.
Note that a negative value will always be returned as an 8
character string.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒHIWORD
Declarations:
function HiWord(LI : LongInt) : Word;
.
Purpose:
Returns the high order word of a LongInt.
.
Comments:
This function is the analog of the system function HI, per-
forming the analogous operation on a LongInt to that performed by
HI on an INTEGER or WORD.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
LoWord
unit ƒShƒUtilPk
ƒLI
Declarations:
function LI(Ilo, Ihi : Word) : LongInt;
.
Purpose:
Converts two Word variables to a LongInt
.
Comments:
.
Examples:
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒLOWORD
Declarations:
function LoWord(LI : LongInt) : Word;
.
Purpose:
Returns the low order word of a LongInt.
.
Comments:
This function is the analog of the system function LO, per-
forming the analogous operation on a LongInt to that performed by
LO on an INTEGER or WORD.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
HiWord
unit ƒShƒUtilPk
ƒPMOD
Declarations:
function Pmod(X, Modulus : LongInt) : LongInt;
.
Purpose:
Returns the remainder of X on division by MODULUS as a
positive number, regardless of the sign of X.
.
Comments:
Recall that, e.g., -1 is congruent to (modulus-1). Thus, for
example, Pmod(-2, 7) will return 5 as the function value.
.
Examples:
(-2 mod 5) = -2
Pmod(-2, 5) = 3
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒPOSSET
Declarations:
function PosSet(A : CharSet; S : string) : byte;
.
Purpose:
Returns the position of the first occurrence of any member
of A in S.
.
Comments:
This function is intended primarily for internal use by
ShUtilPk and ShCmdLin.
.
Examples:
If S = 'X1Y2C3Z4B'
and A = ['A','B','C']
then PosSet(A, S) will return 5.
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒREPALL
Declarations:
procedure RepAll(S1, FS, SS : String; var S2 : string);
function ƒRepAllF(S1, FS, SS : string) : string;
.
Purpose:
In string S1 replace all occurrences of FS with SS
.
Comments:
.
Examples:
See the file TESTUTIL.PAS
.
See also:
DelAll
unit ƒShƒUtilPk
ƒSEARCHENVIRONMENT
Declarations:
function SearchEnvironment(Code : String) : String;
.
Purpose:
Searches the environment space for "CODE" and returns the
corresponding string.
.
Comments:
If the CODE string has not been set with a SET statement,
the function will return an empty string.
.
Examples:
If the DOS command
SET GORP=FooBaz
has been executed, then
SearchEnvironment('GORP')
will return
'FooBaz'
.
See also:
unit ƒShƒUtilPk
ƒSTARSTRING
Declarations:
function StarString(Pattern, Target : String) : Boolean;
.
Purpose:
This function performs a generalization of the wildcard
string matching usually performed by DOS.
.
Comments:
The mask is presented in Pattern, and the string to be
scanned is presented in Target. The function will return TRUE or
FALSE as the target does or does not match the mask.
.
A '*' wild card can be placed anywhere within the mask, and
will represent its usual 'zero or more of any characters'. Scan-
ning will not be terminated at that point, however, but will con-
tinue. Thus, '*B*EFG' will match 'ABCDEFG', but '*B*EGF' will
not. Similarly, '*ABC*' will match, but '*ABC' will not.
.
A '?' wild card can also be placed anywhere within the mask,
and will also represent its usual 'one occurrance of any char-
acter'.
.
Examples:
StarString('*B*EFG', 'ABCDEFG')
returns TRUE.
.
StarString('*B*EGF', 'ABCDEFG')
returns FALSE
but would return TRUE using the DOS algorithm.
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒUNIQUEFILENAME
Declarations:
function UniqueFileName
(Path : String; AddExt : Boolean) : string;
.
Purpose:
Returns a file name which will be unique in the directory
specified by PATH.
.
Comments:
On return, the file name will be appended to PATH to give a
fully qualified path.
.
If AddExt is TRUE, an extension of .$$$ will be appended,
else only the file name will be returned. In either case, the
returned entity is guaranteed to be unique.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
unit ƒShƒUtilPk
ƒWHOAMI
Declarations:
function WhoAmI : String;
.
Purpose:
Returns the fully qualified path to the currently executing
file.
.
Comments:
Can be used with DOS 3.x or above, ONLY.
.
Examples:
See the file TESTUTIL.PAS
.
See also:
ƒBetwS.............. 9-2
ƒBetwU.............. 9-2
ƒC2P................ 3-3
ƒC2PF............... 3-3
ƒCAbs............... 3-4
ƒCAbsF.............. 3-4
ƒCAdd............... 3-4
ƒCAddF.............. 3-4
ƒCConj.............. 3-5
ƒCConjF............. 3-5
ƒCDiv............... 3-5
ƒCDivF.............. 3-5
ƒCharSet............ 2-2
ƒCheckOff........... 6-2
ƒCheckOn............ 6-2
ƒClClose............ 2-3
ƒClInit............. 2-3
ƒClParse............ 2-4
ƒCmp2Str............ 3-6
ƒCmplxError......... 3-6
ƒCmpP2Str........... 3-7
ƒCmpP2StrD.......... 3-7
ƒCMul............... 3-8
ƒCMulF.............. 3-8
ƒColor Constants........
1-1 - 1-3
ƒColorName.......... 1-5
ƒComplex............ 3-3
ƒComplexBaseType.... 3-3
ƒComplexElement..... 3-3
ƒCpPwrR............. 3-8
ƒCpPwrRF............ 3-8
ƒCrcCalc............ 4-2
ƒCrcCopy............ 4-3
ƒCSub............... 3-9
ƒCSubF.............. 3-9
ƒDayStr............. 5-2
ƒDelAll............. 9-3
ƒDelAllF............ 9-3
ƒDelimSet........... 9-1
ƒDelimSetType....... 9-1
ƒdlƒAppend........... 7-4
ƒdlƒCount............ 7-4
ƒdlƒFree............. 7-5
ƒdlƒGetCurrent....... 7-6
ƒdlƒGetFirst......... 7-6
ƒdlƒGetLast.......... 7-7
ƒdlƒGetNext.......... 7-7
ƒdlƒGetPrev.......... 7-8
ƒdlƒLessFunc......... 7-3
ƒdlƒList............. 7-3
ƒdlƒListInit......... 7-9
ƒdlƒNode............. 7-2
ƒdlƒNodePtr.......... 7-2
ƒdlƒPop............. 7-10
ƒdlƒPush............ 7-11
ƒdlƒPut............. 7-12
ƒdlƒPutPrev......... 7-12
ƒdlƒPutSorted....... 7-13
ƒdlƒSpaceUsed....... 7-14
ƒDoW................ 5-3
ƒGetNext............ 9-4
ƒGetNextF........... 9-4
ƒGetSwitch.......... 2-6
ƒGreg2ANSI.......... 5-3
ƒGreg2JDate......... 5-4
ƒGreg2JDN........... 5-4
ƒGreg2Str........... 5-6
ƒGregType........... 5-2
ƒHaltMsg............ 6-3
ƒHEX................ 9-4
ƒHiWord............. 9-5
ƒIm................. 3-3
ƒIntVal............. 2-2
ƒJDate2Greg......... 5-5
ƒJDN2ANSI........... 5-5
ƒJDN2Greg........... 5-6
ƒJDN2Str............ 5-7
ƒLI................. 9-6
ƒLongString......... 8-3
ƒLongStringType..... 8-3
ƒLoWord............. 9-6
ƒlsƒCenter........... 8-5
ƒlsƒCenterCh......... 8-5
ƒlsƒCenterChF........ 8-5
ƒlsƒCenterF.......... 8-5
ƒlsƒCharStr.......... 8-6
ƒlsƒCharStrF......... 8-6
ƒlsƒComp............. 8-7
ƒlsƒCompType......... 8-3
ƒlsƒConcat........... 8-7
ƒlsƒConcatF.......... 8-7
ƒlsƒConcatLs2Str..... 8-7
ƒlsƒConcatLs2StrF.... 8-7
ƒlsƒConcatStr2Ls..... 8-7
ƒlsƒConcatStr2LsF.... 8-7
ƒlsƒCopy............. 8-8
ƒlsƒCopyF............ 8-8
ƒlsƒCount............ 8-9
ƒlsƒCountStr......... 8-9
ƒlsƒCountStrUC....... 8-9
ƒlsƒCountUC.......... 8-9
ƒlsƒDelAll.......... 8-10
ƒlsƒDelAllF......... 8-10
ƒlsƒDelAllStr....... 8-10
ƒlsƒDelAllStrF...... 8-10
ƒlsƒDelAllStrUC..... 8-10
ƒlsƒDelAllStrUCF.... 8-10
ƒlsƒDelAllUC........ 8-10
ƒlsƒDelAllUCF....... 8-11
ƒlsƒDelete.......... 8-12
ƒlsƒDeleteF......... 8-12
ƒlsƒDelimSet......... 8-3
ƒlsƒDelimSetType..... 8-3
ƒlsƒDispose......... 8-12
ƒlsƒGetNext......... 8-13
ƒlsƒGetNextF........ 8-13
ƒlsƒGetNextStr...... 8-13
ƒlsƒGetNextStrF..... 8-13
ƒlsƒInit............ 8-13
ƒlsƒInsert.......... 8-17
ƒlsƒInsertF......... 8-17
ƒlsƒInsertStr....... 8-17
ƒlsƒInsertStrF...... 8-17
ƒlsƒIoff............ 8-14
ƒlsƒIon............. 8-15
ƒlsƒIoResult........ 8-16
ƒlsƒLeftPad......... 8-18
ƒlsƒLeftPadCh....... 8-19
ƒlsƒLeftPadChF...... 8-19
ƒlsƒLeftPadF........ 8-18
ƒlsƒLength.......... 8-20
ƒlsƒLocase.......... 8-20
ƒlsƒLocaseF......... 8-20
ƒlsƒLongString2Str.. 8-21
ƒlsƒPad............. 8-21
ƒlsƒPadCh........... 8-22
ƒlsƒPadChF.......... 8-22
ƒlsƒPadF............ 8-21
ƒlsƒPos............. 8-22
ƒlsƒPosSet.......... 8-23
ƒlsƒPosStr.......... 8-22
ƒlsƒPosStrUC........ 8-22
ƒlsƒPosUC........... 8-22
ƒlsƒReadLn.......... 8-24
ƒlsƒRepAll.......... 8-24
ƒlsƒRepAllF......... 8-24
ƒlsƒRepAllStr....... 8-24
ƒlsƒRepAllStrF...... 8-24
ƒlsƒRepAllStrUC..... 8-24
ƒlsƒRepAllStrUCF.... 8-24
ƒlsƒRepAllUC........ 8-24
ƒlsƒRepAllUCF....... 8-24
ƒlsƒSizeOf.......... 8-25
ƒlsƒStr2LongString.. 8-26
ƒlsƒStr2LongStringF. 8-26
ƒlsƒTransfer........ 8-27
ƒlsƒTrim............ 8-28
ƒlsƒTrimF........... 8-28
ƒlsƒTrimLead........ 8-28
ƒlsƒTrimLeadF....... 8-28
ƒlsƒTrimLeadSet..... 8-29
ƒlsƒTrimLeadSetF.... 8-29
ƒlsƒTrimSet......... 8-30
ƒlsƒTrimSetF........ 8-30
ƒlsƒTrimTrail....... 8-29
ƒlsƒTrimTrailF...... 8-29
ƒlsƒTrimTrailSet.... 8-30
ƒlsƒTrimTrailSetF... 8-30
ƒlsƒUpcase.......... 8-31
ƒlsƒUpcaseF......... 8-31
ƒlsƒWriteLn......... 8-31
ƒMaxLongString...... 8-4
ƒMonthStr........... 5-2
ƒNotFound........... 8-4
ƒNow................ 5-7
ƒNow2Time........... 5-7
ƒNowStr............. 5-8
ƒOrientation........ 1-3
ƒP2C................ 3-9
ƒP2CF............... 3-9
ƒPmod............... 9-7
ƒPopSwitch.......... 2-6
ƒPosSet............. 9-7
ƒRe................. 3-3
ƒReadSwCh........... 2-7
ƒRealVal............ 2-2
ƒRepAll............. 9-8
ƒRepAllF............ 9-8
ƒRingSize........... 8-3
ƒRunErrorMsg........ 6-3
ƒRxC............... 3-10
ƒRxCF.............. 3-10
ƒSearchEnvironment.. 9-8
ƒSelectColors....... 1-3
ƒSetSwCh............ 2-8
ƒslƒAppend........... 7-4
ƒslƒCount............ 7-4
ƒslƒFree............. 7-5
ƒslƒGetCurrent....... 7-6
ƒslƒGetFirst......... 7-6
ƒslƒGetLast.......... 7-7
ƒslƒGetNext.......... 7-7
ƒslƒList............. 7-3
ƒslƒListInit......... 7-9
ƒslƒNode............. 7-2
ƒslƒNodePtr.......... 7-2
ƒslƒPop............. 7-10
ƒslƒPush............ 7-11
ƒslƒPut............. 7-12
ƒslƒSpaceUsed....... 7-14
ƒSSM2Time........... 5-8
ƒSSM2TimeStr........ 5-9
ƒStarString......... 9-9
ƒStartingAttr....... 9-1
ƒStartingMode....... 9-1
ƒStrVal............. 2-2
ƒSwRec.............. 2-2
ƒSwVal.............. 2-2
ƒTime2SSM........... 5-9
ƒTime2TimeStr...... 5-10
ƒTimeType........... 5-2
ƒToday............. 5-10
ƒToday2ANSI........ 5-11
ƒToday2Greg........ 5-11
ƒTodayStr.......... 5-12
ƒUniqueFileName..... 9-9
ƒValueType.......... 2-2
ƒVtInt.............. 2-2
ƒVtReal............. 2-2
ƒVtStr.............. 2-2
ƒWhoAmI............ 9-10