Unit WAStrUtl

Renamed from StrUtils.pas 6/14/1998 Paul Rice to avoid conflicts with others' work. +----------------------------------------------------------------------------+ | İ İ | | İİ İ İ İ | | İİİ İ İ İ | | İİ İ İ İ | | İ İİ İ İ | | İ İ İİİ İİ İ | | İİ İ İ İİİİİİİİİİ İ | | İ İİ İİ İİİİİİİİİİİİİİİ | | İ İİİ İİİİİİ İİİ İ İİİİİİİİ | | İ İİ İİİİİİİİİİİİ İ İİİİİİİİİİ Copyright İ 1996-1997 by: | | İ İİİİİİ İİİİİİİİİİİ İ İİİİİ İİ | | İ İİİİİİİ İİİİİ İİİİ İİ İİ İ WHITE ANTS SYSTEMHOUSE BV | | İ İİİİİİİ İİİ İİİ İİ İ İİİİ Geleen 12 | | İ İİİİİİİ İ İİ İİİ İ 8032 GB Zwolle | | İİİİİİ İ İ İ Netherlands | | İİİ İİİİİ İ İİ İ İ | | İİ İ İ İİİ İ Tel. +31 38 453 86 31 | | İ İ İ Fax. +31 38 453 41 22 | | İ İ İİ | | İ İ İİ www.whiteants.com | | İİ İ İ İ support@whiteants.com | | İ | +----------------------------------------------------------------------------+ file : StrUtils version : 1.01 comment : Part of this file was taken form S_STRING.PAS by RAY LISCHNER Book: Secrets of Delphi 2.0 author : G. Beuze, R. Post, L. Laarhoven, R. Lischner compiler : Delphi 1.0, partly Delphi 2.0 +----------------------------------------------------------------------------+ | DISCLAIMER: | | THIS SOURCE IS FREEWARE. YOU ARE ALLOWED TO USE IT IN YOUR OWN PROJECTS | | WITHOUT ANY RESTRICTIONS. YOU ARE NOT ALLOWED TO SELL THE SOURCE CODE. | | THERE IS NO WARRANTY AT ALL - YOU USE IT ON YOUR OWN RISC. WHITE ANTS DOES | | NOT ASSUME ANY RESPONSIBILITY FOR ANY DAMAGE OR ANY LOSS OF TIME OR MONEY | | DUE THE USE OF ANY PART OF THIS SOURCE CODE. | +----------------------------------------------------------------------------+

Classes

Functions

AbbrStr - Returns number of leading tabs
BCDtoByte - Returns BCD coded representation of a
BlankString - Returns a string of length (Cnt), filled with C
ByteToBCD - Returns S^ or '' if s = nil
ByteToBinaryStr - Returns Byte value of BCD coded byte a
CharString - Removes any leading and trailing character C from S
DelChars -
DelLeftChars - Removes any characters #0.
DelLeftRightChars - Removes any trailing character C from S
DelRightChars - Removes any leading character C from S
DelWhiteSpace - Removes any character C from S
GetIndex - Returns 'template' as in TEMPLATE0001
GetName - Returns True if a number was found to the right of Str for example as in 'Button123'.
GetNameAndValue - Returns Value as in: Name=Value , or '' if no = was found
GetTemplate - Converts S to extended, on exception returns DefValue
GetTemplateAndIndex - Returns Index = 1 as in TEMPLATE0001
GetValue - Returns Name as iN: Name=Value , or '' if no = was found
IsPrefix - Returns S in lower case except the first char which is upper: 'example' -> 'Example', 'EXAMPLE' -> 'Example'
LeadBlanksCnt - Returns number of leading chars C
LeadCharsCnt - Returns a string a Cnt blanks
LeadTabCnt - Returns number of leading blanks
LongToBinaryStr - Returns '00011100|00011100' style string, with | defined by ByteDelimiter const, See NibbleDelimiter
MatchStrings - Returns '00011100|00011100|00011100|00011100' style string, see Delimiters

-------------------------------------------------------------------------} This function takes two strings and compares them.
MixedCase - Returns a string with length <= MaxLen.
StringValue - Returns True if Str starts with SubStr ignoring case
StrToFloatDef - Returns True if Source matches Pattern '*Example?*' etc } { Orignal code by Sean Stanley in C, Rewritten in Delphi by David Stidolph
StrToPChar - Convert a Pascal string to a PChar.
WordToBinaryStr - Returns '0001.

Types

Constants

ByteDelimiter
NibbleDelimiter

Variables


Functions


function AbbrStr(const Source: string; MaxLen: Byte): string;

Returns number of leading tabs

function BCDtoByte(a : Byte) : Byte;

Returns BCD coded representation of a

function BlankString(Cnt: Byte): string;

Returns a string of length (Cnt), filled with C

function ByteToBCD(a: Byte): Byte;

Returns S^ or '' if s = nil

function ByteToBinaryStr(B: Byte): string;

Returns Byte value of BCD coded byte a

function CharString(C: Char; Cnt: Byte): string;

Removes any leading and trailing character C from S

function DelChars(const Str: string; C: Char): string;


function DelLeftChars(const Str: string; C: Char): string;

Removes any characters #0..#32 from Str

function DelLeftRightChars(const Str: string; C: Char): string;

Removes any trailing character C from S

function DelRightChars(const Str: string; C: Char): string;

Removes any leading character C from S

function DelWhiteSpace(const Str: string): string;

Removes any character C from S

function GetIndex(const Str: string): Integer;

Returns 'template' as in TEMPLATE0001

function GetName(const S: string): string;

Returns True if a number was found to the right of Str for example as in 'Button123'. Returns Button in Template and 123 in Index Returns False if no number was found

function GetNameAndValue(const S: string; var Name, Value: string): Boolean;

Returns Value as in: Name=Value , or '' if no = was found

function GetTemplate(const Str: string): string;

Converts S to extended, on exception returns DefValue

function GetTemplateAndIndex(const Str: string; var Template: string; var Index: Integer): Boolean;

Returns Index = 1 as in TEMPLATE0001

function GetValue(const S: string): string;

Returns Name as iN: Name=Value , or '' if no = was found

function IsPrefix(const SubStr, Str: string): Boolean;

Returns S in lower case except the first char which is upper: 'example' -> 'Example', 'EXAMPLE' -> 'Example'

function LeadBlanksCnt(const S: string): Byte;

Returns number of leading chars C

function LeadCharsCnt(const S: string; C: Char): Byte;

Returns a string a Cnt blanks

function LeadTabCnt(const S: string): Byte;

Returns number of leading blanks

function LongToBinaryStr(L: LongInt): string;

Returns '00011100|00011100' style string, with | defined by ByteDelimiter const, See NibbleDelimiter

function MatchStrings(const Source, Pattern: string): Boolean;

Returns '00011100|00011100|00011100|00011100' style string, see Delimiters

-------------------------------------------------------------------------} This function takes two strings and compares them. The first string can be anything, but should not contain pattern characters (* or ?). The pattern string can have as many of these pattern characters as you want. For example: MatchStrings('David Stidolph','*St*') would return True. Orignal code by Sean Stanley in C Rewritten in Delphi by David Stidolph {-------------------------------------------------------------------------


function MixedCase(const Str: string): string;

Returns a string with length <= MaxLen. Abbreviating on words

function StringValue(S: PString): string;

Returns True if Str starts with SubStr ignoring case

function StrToFloatDef(const Str: string; DefValue: Extended): Extended;

Returns True if Source matches Pattern '*Example?*' etc } { Orignal code by Sean Stanley in C, Rewritten in Delphi by David Stidolph

function StrToPChar(const Str: string): PChar;

Convert a Pascal string to a PChar.

Delphi 2.0 knows how to convert string to PChar.


function WordToBinaryStr(W: Word): string;

Returns '0001.1100' style string, with . defined by NibbleDelimiter const

Types


Constants

ByteDelimiter = ' '

NibbleDelimiter = '.'

Delimiters use by XXXToBinaryStr procedures

Variables