⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 esbrtns.pas

📁 详细说明:毕业论文中关于小型宾馆管理系统的详细设计毕 业论文中关于小型宾馆...一个酒店管理系统VB+Access [学生学籍管理系统(VB+Acess).zip] - !这个是刚刚编的毕业设计,可能
💻 PAS
字号:
unit ESBRtns;

{    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
}

interface

const
	MaxByte: Byte = 255;
	MaxShortInt: ShortInt = 127;
	MaxWord: Word = 65535;
	MaxReal: Real = 1.7e38;
	MaxSingle: Single = 3.4e38;
	MaxDouble: Double = 1.7e308;
	MaxExtended: Extended = 1.1e4932;
	MaxComp: Comp = 9.2e18;

	MinByte: Byte = 0;
	MinShortInt: ShortInt = -128;
	MinInt: Integer = -32768;
	MinWord: Word = 0;
	MinLongInt: LongInt = $80000000;
	MinReal: Real = 2.9e-39;
	MinSingle: Single = 1.5e-45;
	MinDouble: Double = 5.0e-324;
	MinExtended: Extended = 3.4e-4932;

const
	NumPadCh: Char = ' '; // Character to use for Left Hand Padding of Numerics

type
	TBitList = Word; // Used for a Bit List of 16 bits from 15 -> 0
	TLongBitList = LongInt; // Used for a Bit List of 32 bits from 31 -> 0

type
	String16 = string [16];
	String32 = string [32];


{*** Bit Manipulation ***}

procedure ClearAllBits (var Body: TBitList);

{ Sets all Bits to 0 }

procedure SetAllBits (var Body: TBitList);

{ Sets all Bits to 1 }

procedure FlipAllBits (var Body: TBitList);

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

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

{ Sets specified Bit to 0 }

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

{ Sets specified Bit to 1 }

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

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

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

{ Returns True if Specified Bit is 1 }

procedure ReverseBits (var Body: TBitList); register;

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

function Bits2Str (const Body: TBitList): String16;

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

function Str2Bits (const S: String16): TBitList; register;

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

function BitsSet (const Body: TBitList): Byte; register;

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

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

{ Converts an Array of Boolean into a BitList }

procedure ClearAllLBits (var Body: TLongBitList);

	{ Sets all Bits to 0 }

procedure SetAllLBits (var Body: TLongBitList);

	{ Sets all Bits to 1 }

procedure FlipAllLBits (var Body: TLongBitList);

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

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

	{ Sets specified Bit to 0 }

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

	{ Sets specified Bit to 1 }

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

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

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

	{ Returns True if Specified Bit is 1 }

function LBits2Str (const Body: TLongBitList): String32;

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

{*** Block Operations ***}

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

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

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

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

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

{ Fills given structure with specified number of $FF values,
	effectively setting it. }

{*** String to Integer Types ***}

function Str2LInt (const S: String): LongInt;

{ Converts a String into a LongInt }

function Str2Byte (const S: String): Byte;

{ Converts a String into a Byte }

function Str2SInt (const S: String): ShortInt;

{ Converts a String into a ShortInt }

function Str2Int (const S: String): Integer;

{ Converts a String into an Integer }

function Str2Word (const S: String): Word;

{ Converts a String into a Word }

{*** Integer Types to Strings ***}

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

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

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 LInt2ZStr (const L: LongInt; const Len: Byte): String;

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

function LInt2ZBStr (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 LInt2CStr (const L : LongInt; const Len : Byte): string;

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

function LInt2EStr (const L: LongInt): String;

{ Convert a LongInt into an exact String, No Padding }

function LInt2ZBEStr (const L: LongInt): String;

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

function LInt2CEStr (const L : LongInt): string;

{ Convert a LongInt into a Comma'ed String without Padding }

{*** Extended Reals to Strings ***}

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

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

function Ext2EStr2 (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 Ext2CEStr (const E: Extended; 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 Double2EStr (const D: Double; const Decimals: Byte): String;

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

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

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

function Comp2EStr (const C: Comp): String;

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

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

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

function Comp2CEStr (const C : Comp): string;

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

function Ext2Str (const E: Extended; 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 }

function Double2Str (const D: Double; 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 Single2Str (const S: Single; const Len, Decimals: Byte): String;

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

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

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

{*** Strings to Extended Reals ***}

function Str2Ext (const S: String): Extended;

{ Converts a String into an Extended Real }

{*** Extra String Operations ***}

function LeftStr (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. }

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

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

function LeftTillStr (const S : string; const Ch : Char): 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 RightAfterStr (const S : String; const N : Integer): String;

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

function RightAfterChStr (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 StripTChStr (const S : string; const Ch : Char): string;

{ Returns the String with all specified trailing characters	removed. }

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

{ Returns the String with all specified leading characters removed. }

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

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

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

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

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

{ Returns a string composed of N occurrences of Ch. }

function BlankStr (const N : Integer): string;

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

function DashStr (const N : Integer): String;

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

function DDashStr (const N : Integer): string;

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

function LineStr (const N : Integer): string;

{ Returns a string composed of N occurrences of '

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -