Unit ESBRtns

Classes

Functions

BitIsSet - Flips specified Bit, i.
Bits2Str - Reverses the Bit List, i.
BitsSet - Converts a string of '1' and '0' into a BitList.
BlankStr - Returns a string composed of N occurrences of Ch.
Boolean2Char - Converts a Boolean Value into the corresponding Character: True -> 'Y' False -> 'N'
Boolean2TF -
Boolean2YN - Converts a Boolean Value into the corresponding Character: True -> 'T' False -> 'F'
Booleans2BitList - Returns a number from 0 -> 16 indicating the number of Bits Set

if no carry then no increment
Byte2Str - Converts a LongInt into a String of length N with NumPadCh Padding to the Left
CentreChStr - Returns a string with specified characters added to the beginning of the string until the string is of the given length.
CentreStr - Returns a string with blank spaces added to the beginning of the string until the string is of the given length.
ClearAllBits - * Bit Manipulation

** Bit Manipulation
ClearAllLBits - Converts an Array of Boolean into a BitList
ClearBit - Flips all Bits, i.
ClearLBit - Flips all Bits, i.
Comp2CEStr - Converts a Comp (Integral) Real into a Comma'ed String of specified Length, Len, NumPadCh used for Left padding
Comp2CStr - Converts a Comp (Integral) Real into an exact String, No padding
Comp2EStr - Converts a Single Real into an exact String, No padding, with given number of Decimal Places
Comp2Str - Converts an Single Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals
DashStr - Returns a string composed of N blank spaces (i.
DDashStr - Returns a string composed of N occurrences of '-'.
DLineStr - Returns a string composed of N occurrences of 'Ä' (196).
Double2EStr - Converts an Extended Real into an exact String, No padding, with given number of Decimal Places, with Commas separating thousands
Double2Str - Converts an Extended Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals
ESBClear - Moves Size bytes from Source starting at Ofs1 to destination starting at Ofs 2 using fast dword moves.
ESBMoveOfs - Converts a Bit list to a string of '1' and '0'.
ESBSet - Fills given structure with specified number of 0 values, effectively clearing it.
Ext2CEStr - Converts an Extended Real into an exact String, No padding, with at most given number of Decimal Places
Ext2EStr - Convert a LongInt into a Comma'ed String without Padding } {*** Extended Reals to Strings
Ext2EStr2 - Converts an Extended Real into an exact String, No padding, with given number of Decimal Places
Ext2Str - Converts a Comp (Integral) Real into a Comma'ed String without Padding
FillStr - Returns the String with all occurrences of OldCh character replaced with NewCh character.
FlipAllBits - Sets all Bits to 1
FlipAllLBits - Sets all Bits to 1
FlipBit - Sets specified Bit to 1
FlipLBit - Sets specified Bit to 1
HashStr - Returns a string composed of N occurrences of '*'.
LBitIsSet - Flips specified Bit, i.
LBits2Str - Returns True if Specified Bit is 1
LeftAlignStr - Returns a string with specified characters added to the beginning and end of the string to in effect centre the string within the given length.
LeftStr - Converts a String into an Extended Real } {*** Extra String Operations
LeftTillStr - Returns the substring consisting of the last N characters of S.
LineStr - Returns a string composed of N occurrences of '='.
LInt2CEStr - Convert a LongInt into an exact String, No Padding, with null returned if Value is 0
LInt2CStr - Converts a LongInt into a String of length N with NumPadCh Padding to the Left, with blanks returned if Value is 0
LInt2EStr - Convert a LongInt into a Comma'ed String of length Len, with NumPadCh Padding to the Left
LInt2Str - Converts a String into a Word } {*** Integer Types to Strings
LInt2ZBEStr - Convert a LongInt into an exact String, No Padding
LInt2ZBStr - Converts a LongInt into a String of length N with NumPadCh Padding to the Left
LInt2ZStr - Converts a LongInt into a String of length N with NumPadCh Padding to the Left
PadChLeftStr - Returns a string with specified characters added to the end of the string until the string is of the given length.
PadChRightStr - Returns a string with blank spaces added to the beginning and end of the string to in effect centre the string within the given length.
PadLeftStr - Returns a string with blank spaces added to the end of the string until the string is of the given length.
PadRightStr - Returns a string composed of N occurrences of '#'.
ReplaceChStr - Returns the String with all specified leading and trailing characters removed.
ReverseBits - Returns True if Specified Bit is 1
RightAfterChStr - Returns the sub-string to the right AFTER the first N Characters.
RightAfterStr - Returns the substring consisting of the characters from S up to but not including the specified one.
RightAlignStr -
RightStr - Returns the substring consisting of the first N characters of S.
SetAllBits - Sets all Bits to 0
SetAllLBits - Sets all Bits to 0
SetBit - Sets specified Bit to 0
SetLBit - Sets specified Bit to 0
Single2EStr - Converts a Double Real into an exact String, No padding, with given number of Decimal Places
Single2Str - Converts a Double Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals
StarStr - Returns a string composed of N occurrences of 'Í' (205).
Str2Bits - Converts a Bit list to a string of '1' and '0'.
Str2Byte - Converts a String into a LongInt
Str2Ext - Converts a Comp (Integral) Real into a String of specified Length, using NumPadCh for Left Padding } {*** Strings to Extended Reals
Str2Int - Converts a String into a ShortInt
Str2LInt - Fills given structure with specified number of $FF values, effectively setting it.
Str2SInt - Converts a String into a Byte
Str2Word - Converts a String into an Integer
StripChStr - Returns the String with all specified leading characters removed.
StripLChStr - Returns the String with all specified trailing characters removed.
StripTChStr - Returns the sub-string to the right AFTER the first ocurrence of specifiec character.
TF2Boolean - Converts a Boolean Value into the corresponding Character: True -> TrueChar False -> FalseChar
YN2Boolean - Converts a Character Value into its corresponding Boolean value: 'T', 't' -> True Otherwise -> False

Types

String16
String32
TBitList
TLongBitList

Constants

MaxByte
MaxComp
MaxDouble
MaxExtended
MaxReal
MaxShortInt
MaxSingle
MaxWord
MinByte
MinDouble
MinExtended
MinInt
MinLongInt
MinReal
MinShortInt
MinSingle
MinWord
NumPadCh

Variables


Functions


function BitIsSet (const Body: TBitList; const I: Byte): Boolean;

Flips specified Bit, i.e. 0 -> 1 and 1 -> 0

function Bits2Str (const Body: TBitList): String16;

Reverses the Bit List, i.e. Bit 15 <-> Bit 0, Bit 14 <-> Bit1, etc.

function BitsSet (const Body: TBitList): Byte;

Converts a string of '1' and '0' into a BitList.

result must be in ax


function BlankStr (const N : Integer): string;

Returns a string composed of N occurrences of Ch.

function Boolean2Char (const B : Boolean; TrueChar, FalseChar: Char): Char;

Converts a Boolean Value into the corresponding Character: True -> 'Y' False -> 'N'

function Boolean2TF (const B : Boolean): Char;


function Boolean2YN (const B : Boolean): Char;

Converts a Boolean Value into the corresponding Character: True -> 'T' False -> 'F'

function Booleans2BitList (const B: array of Boolean): TBitList;

Returns a number from 0 -> 16 indicating the number of Bits Set

if no carry then no increment


function Byte2Str (const L: LongInt; const Len: Byte): String;

Converts a LongInt into a String of length N with NumPadCh Padding to the Left

function CentreChStr (const S : String; const Ch : Char; const Len : Integer): String;

Returns a string with specified characters added to the beginning of the string until the string is of the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

function CentreStr (const S : String; const Len : Integer): String;

Returns a string with blank spaces added to the beginning of the string until the string is of the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

procedure ClearAllBits (var Body: TBitList);

* Bit Manipulation

** Bit Manipulation


procedure ClearAllLBits (var Body: TLongBitList);

Converts an Array of Boolean into a BitList

procedure ClearBit (var Body: TBitList; const I: Byte);

Flips all Bits, i.e 1 -> 0 and 0 -> 1

procedure ClearLBit (var Body: TLongBitList; const I: Byte);

Flips all Bits, i.e 1 -> 0 and 0 -> 1

function Comp2CEStr (const C : Comp): string;

Converts a Comp (Integral) Real into a Comma'ed String of specified Length, Len, NumPadCh used for Left padding

function Comp2CStr (const C : Comp; const Len : Byte): string;

Converts a Comp (Integral) Real into an exact String, No padding

function Comp2EStr (const C: Comp): String;

Converts a Single Real into an exact String, No padding, with given number of Decimal Places

function Comp2Str (const C: Comp; const Len : Byte): String;

Converts an Single Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals

function DashStr (const N : Integer): String;

Returns a string composed of N blank spaces (i.e. #32)

function DDashStr (const N : Integer): string;

Returns a string composed of N occurrences of '-'.

function DLineStr (const N : Integer): string;

Returns a string composed of N occurrences of 'Ä' (196).

function Double2EStr (const D: Double; const Decimals: Byte): String;

Converts an Extended Real into an exact String, No padding, with given number of Decimal Places, with Commas separating thousands

function Double2Str (const D: Double; const Len, Decimals: Byte): String;

Converts an Extended Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals

procedure ESBClear (var Dest; const Size: Integer);

Moves Size bytes from Source starting at Ofs1 to destination starting at Ofs 2 using fast dword moves. BASM

point to last byte of rest


procedure ESBMoveOfs (const Source; const Ofs1: Integer; var Dest; const Ofs2: Integer; const Size: Integer);

Converts a Bit list to a string of '1' and '0'. ) {*** Block Operations

procedure ESBSet (var Dest; const Size: Integer);

Fills given structure with specified number of 0 values, effectively clearing it.

function Ext2CEStr (const E: Extended; const Decimals: Byte): String;

Converts an Extended Real into an exact String, No padding, with at most given number of Decimal Places

function Ext2EStr (const E: Extended; const Decimals: Byte): String;

Convert a LongInt into a Comma'ed String without Padding } {*** Extended Reals to Strings

function Ext2EStr2 (const E: Extended; const Decimals: Byte): String;

Converts an Extended Real into an exact String, No padding, with given number of Decimal Places

function Ext2Str (const E: Extended; const Len, Decimals: Byte): String;

Converts a Comp (Integral) Real into a Comma'ed String without Padding

function FillStr (const Ch : Char; const N : Integer): string;

Returns the String with all occurrences of OldCh character replaced with NewCh character.

procedure FlipAllBits (var Body: TBitList);

Sets all Bits to 1

procedure FlipAllLBits (var Body: TLongBitList);

Sets all Bits to 1

procedure FlipBit (var Body: TBitList; const I: Byte);

Sets specified Bit to 1

procedure FlipLBit (var Body: TLongBitList; const I: Byte);

Sets specified Bit to 1

function HashStr (const N : Integer): string;

Returns a string composed of N occurrences of '*'.

function LBitIsSet (const Body: TLongBitList; const I: Byte): Boolean;

Flips specified Bit, i.e. 0 -> 1 and 1 -> 0

function LBits2Str (const Body: TLongBitList): String32;

Returns True if Specified Bit is 1

function LeftAlignStr (const S : string; const N : Integer): string;

Returns a string with specified characters added to the beginning and end of the string to in effect centre the string within the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

function LeftStr (const S : string; const N : Integer): string;

Converts a String into an Extended Real } {*** Extra String Operations

function LeftTillStr (const S : string; const Ch : Char): string;

Returns the substring consisting of the last N characters of S. If N > Length (S) then the substring = S.

function LineStr (const N : Integer): string;

Returns a string composed of N occurrences of '='.

function LInt2CEStr (const L : LongInt): string;

Convert a LongInt into an exact String, No Padding, with null returned if Value is 0

function LInt2CStr (const L : LongInt; const Len : Byte): string;

Converts a LongInt into a String of length N with NumPadCh Padding to the Left, with blanks returned if Value is 0

function LInt2EStr (const L: LongInt): String;

Convert a LongInt into a Comma'ed String of length Len, with NumPadCh Padding to the Left

function LInt2Str (const L: LongInt; const Len: Byte): String;

Converts a String into a Word } {*** Integer Types to Strings

function LInt2ZBEStr (const L: LongInt): String;

Convert a LongInt into an exact String, No Padding

function LInt2ZBStr (const L: LongInt; const Len: Byte): String;

Converts a LongInt into a String of length N with NumPadCh Padding to the Left

function LInt2ZStr (const L: LongInt; const Len: Byte): String;

Converts a LongInt into a String of length N with NumPadCh Padding to the Left

function PadChLeftStr (const S : string; const Ch : Char; const Len : Integer): string;

Returns a string with specified characters added to the end of the string until the string is of the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

function PadChRightStr (const S : string; const Ch : Char; const Len : Integer): string;

Returns a string with blank spaces added to the beginning and end of the string to in effect centre the string within the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

function PadLeftStr (const S : string; const Len : Integer): string;

Returns a string with blank spaces added to the end of the string until the string is of the given length. If Length (S) >= Len then NO padding occurs, and S is returned.

function PadRightStr (const S : string; const Len : Integer): string;

Returns a string composed of N occurrences of '#'.

function ReplaceChStr (const S : string; const OldCh, NewCh : Char): string;

Returns the String with all specified leading and trailing characters removed.

procedure ReverseBits (var Body: TBitList);

Returns True if Specified Bit is 1

function RightAfterChStr (const S : String; const Ch : Char): String;

Returns the sub-string to the right AFTER the first N Characters. if N >= Length (S) then a Null string is returned.

function RightAfterStr (const S : String; const N : Integer): String;

Returns the substring consisting of the characters from S up to but not including the specified one. If the specified character is not found then a null string is returned.

function RightAlignStr (const S : string; const N : Integer): string;


function RightStr (const S : string; const N : Integer): string;

Returns the substring consisting of the first N characters of S. If N > Length (S) then the substring = S.

procedure SetAllBits (var Body: TBitList);

Sets all Bits to 0

procedure SetAllLBits (var Body: TLongBitList);

Sets all Bits to 0

procedure SetBit (var Body: TBitList; const I: Byte);

Sets specified Bit to 0

procedure SetLBit (var Body: TLongBitList; const I: Byte);

Sets specified Bit to 0

function Single2EStr (const S: Single; const Decimals: Byte): String;

Converts a Double Real into an exact String, No padding, with given number of Decimal Places

function Single2Str (const S: Single; const Len, Decimals: Byte): String;

Converts a Double Real into a String of specified Length, using NumPadCh for Left Padding, and with Specified number of Decimals

function StarStr (const N : Integer): string;

Returns a string composed of N occurrences of 'Í' (205).

function Str2Bits (const S: String16): TBitList;

Converts a Bit list to a string of '1' and '0'.

add in the carry bit


function Str2Byte (const S: String): Byte;

Converts a String into a LongInt

function Str2Ext (const S: String): Extended;

Converts a Comp (Integral) Real into a String of specified Length, using NumPadCh for Left Padding } {*** Strings to Extended Reals

function Str2Int (const S: String): Integer;

Converts a String into a ShortInt

function Str2LInt (const S: String): LongInt;

Fills given structure with specified number of $FF values, effectively setting it. } {*** String to Integer Types

function Str2SInt (const S: String): ShortInt;

Converts a String into a Byte

function Str2Word (const S: String): Word;

Converts a String into an Integer

function StripChStr (const S : string; const Ch : Char): string;

Returns the String with all specified leading characters removed.

function StripLChStr (const S : string; const Ch : Char): string;

Returns the String with all specified trailing characters removed.

function StripTChStr (const S : string; const Ch : Char): string;

Returns the sub-string to the right AFTER the first ocurrence of specifiec character. If Ch not found then a Null String is returned.

function TF2Boolean (const Ch : Char): Boolean;

Converts a Boolean Value into the corresponding Character: True -> TrueChar False -> FalseChar

function YN2Boolean (const Ch : Char): Boolean;

Converts a Character Value into its corresponding Boolean value: 'T', 't' -> True Otherwise -> False

Types


String16 = string [16]
Used for a Bit List of 32 bits from 31 -> 0
String32 = string [32]

TBitList = Word
Character to use for Left Hand Padding of Numerics
TLongBitList = LongInt
Used for a Bit List of 16 bits from 15 -> 0

Constants

MaxByte = 255

v1.1 14 Nov 1997 - 32-Bit Bit Lists added v1.0 Intial Releas Miscellaneous Routines to enhance your 32-bit Delphi Programming including: - 16-bit Bit Lists - Block Operations - various String Routines and Conversions (c) 1997 ESB Consultancy These routines are used by ESB Consultancy within the development of their Customised Application. ESB Consultancy retains full copyright. ESB Consultancy grants users of this code royalty free rights to do with this code as they wish. We does ask that if this code helps you in you development that you send as an email mailto:esb@gold.net.au or even a local postcard. It would also be nice if you gave us a mention in your About Box or Help File. ESB Consultancy Home Page: http://www.gold.net.au/~esb Mail Address: PO Box 2259, Boulder, WA 6432 AUSTRALIA

MaxComp = 9.2e18

MaxDouble = 1.7e308

MaxExtended = 1.1e4932

MaxReal = 1.7e38

MaxShortInt = 127

MaxSingle = 3.4e38

MaxWord = 65535

MinByte = 0

MinDouble = 5.0e-324

MinExtended = 3.4e-4932

MinInt = -32768

MinLongInt = $80000000

MinReal = 2.9e-39

MinShortInt = -128

MinSingle = 1.5e-45

MinWord = 0

NumPadCh = ' '


Variables