Unit INIMis

****************************************************** ****************************************************** Project: Delphi Initialization Database Author: JBD E-mail: binel@alf.tel.hr Comment: Miscellaneous functions ******************************************************

Classes

Functions

AddDays -
AddDaysStr -
AddToDateStr -
AllDelete -
AllTrim -
Blanks -
Capitalize -
CheckDirectory -
cIf -
CodeString -
CP852LowerCase -
CP852UpperCase -
Day -
DeleteChars -
DiffDays -
DiffDaysStr -
DumpMemString -
EnCodeString -
Expand -
fIf -
FileNameWithoutExt -
FillListWithTokens -
GetNthToken -
GetPercentOf -
GetToken -
iIf -
IncrementString -
Left -
LeftToCh -
LimitValue -
LTrim -
MakeIdent -
MakeShortSection -
Max -
MergePaths -
Min -
Month -
NumToken -
OnlyAlnum -
PadAll -
PadLeft -
PadRight -
ParseStringOfBytes -
Replicate -
ReplicateStr -
ResStr -
Right -
RightFromCh -
RND -
RTrim -
Space -
StrHEXToInt -
StrICmp -
strIf -
StrNCmp -
StrNICmp -
StrOCTToInt -
StrToFloatDef -
StrXToInt -
SumPercents -
TypeOfLimit -
ValidFileName -
ValidFileNameExt -
ValidString -
Year -
Year100 -

Types

TExpandWhere
TIntBase
TLimitType
TScanTokenState
TSetOfSymbols

Constants

CAddSign
CAskDeleteRecord
CCodeKey
cEmpty
CFZero
CIntBaseBINSet
CIntBaseBINStr
CIntBaseDECSet
CIntBaseDECStr
CIntBaseHEXSet
CIntBaseHEXStr
CIntBaseOCTSet
CIntBaseOCTStr
CMsgCannotDelete
CMsgErrBadFilename
CMsgErrDCBCreate
CMsgErrFileCreate
CMsgErrPortOpen
CMsgFormNoExists
cNull
CResAbout
CResBeSmart
CResInitMsg
CResInitMsgForm
CResStartTitle
CResTableActionFail
CResTitleAbout
csAllCharacters
csAlnum
csDirectoryRange
csMaskRange
csNormalFileRange
csNumAlpha
csOnOff
cstrFalse
CStrNotAvail
cstrTrue
CSubSign
csYesNo
CTrue
CVerMajor
CVerMinor

Variables


Functions


function AddDays(dateFrom:TDateTime;Days:Integer):TDateTime;


function AddDaysStr(const sDateFrom:string;Days:Integer):string;


function AddToDateStr(const sDateFrom:string;Sel,Sign:Integer):string;


function AllDelete(Where:string;WhatToDelete:TSetOfSymbols):string;


function AllTrim(const What:string):string;


function Blanks(const Where:string):Integer;


function Capitalize(const SWord:string):string;


function CheckDirectory(const Path:string):Boolean;


function cIf(Condition:Boolean;IfTrue,IfFalse:Char):Char;


function CodeString(const toCode,Key:string):string;


function CP852LowerCase(const sStr:string):string;


function CP852UpperCase(const sStr:string):string;


function Day(dD:TDateTime):Word;


function DeleteChars(const Where:string;Chars:TSetOfSymbols):string;


function DiffDays(dateFrom,dateTo:TDateTime):Integer;


function DiffDaysStr(const sDateFrom,sDateTo:string):Integer;


function DumpMemString(const sMem:string):string;


function EnCodeString(const toCode,Key:string):string;


function Expand(WithCh:Char;Space:Integer;Add:string;Location:TExpandWhere):string;


function fIf(Condition:Boolean;IfTrue,IfFalse:Double):Double;


function FileNameWithoutExt(const fName:string):string;


function FillListWithTokens(const Sentence:string;TokenSet:TSetOfSymbols;List:TStringList):Integer;


function GetNthToken(const Sentence:string;tN:Integer;DelimSet:TSetOfSymbols):string;


function GetPercentOf(Value,Percent:Double):Double;


function GetToken(const Sentence:string;TokenSet:TSetOfSymbols;var Offset:Integer):string;


function iIf(Condition:Boolean;IfTrue,IfFalse:LongInt):LongInt;


function IncrementString(const sStr:string):string;


function Left(const FromS:string;NOfCh:Integer):string;


function LeftToCh(const FromS:string;Ch:Char):string;


function LimitValue(Value,iMin,iMax:LongInt):LongInt;


function LTrim(What:string):string;


function MakeIdent(const Text:string):string;


function MakeShortSection(const sec:string):string;


function Max(x,y:LongInt):LongInt;


function MergePaths(const Path,Name:string):string;


function Min(x,y:LongInt):LongInt;


function Month(dD:TDateTime):Word;


function NumToken(const Sentence:string;TokenSet:TSetOfSymbols):Integer;


function OnlyAlnum(const Where:string):string;


function PadAll(WithCh:Char;Space:Integer;Add:string):string;


function PadLeft(WithCh:Char;Space:Integer;Add:string):string;


function PadRight(WithCh:Char;Space:Integer;Add:string):string;


function ParseStringOfBytes(const sBytes:string;DefBase:TIntBase):string;


function Replicate(Dimension:Byte;Ch:Char):string;


function ReplicateStr(Dimension:Byte;const sStr:string):string;


function ResStr(resStrId:Integer):string;


function Right(const FromS:string;NOfCh:Integer):string;


function RightFromCh(const FromS:string;Ch:Char):string;


function RND(Lo,Hi:Integer):Integer;


function RTrim(What:string):string;


function Space(Dimension:Byte):string;


function StrHEXToInt(const sStr:string):Integer;


function StrICmp(const S1,S2:string):Boolean;


function strIf(Condition:Boolean;const IfTrue,IfFalse:string):string;


function StrNCmp(const S1,S2:string;Len:Integer):Boolean;


function StrNICmp(const S1,S2:string;Len:Integer):Boolean;


function StrOCTToInt(const sStr:string):Integer;


function StrToFloatDef(const s:string;dDef:Extended):Extended;


function StrXToInt(const sStr,BaseString:string):Integer;


function SumPercents(p1,p2:Double):Double;


function TypeOfLimit(iMin,iMax:LongInt):TLimitType;


function ValidFileName(const Name:string):Boolean;


function ValidFileNameExt(const Name:string):Boolean;


function ValidString(const Name:string;sChars:TSetOfSymbols):Boolean;


function Year(dD:TDateTime):Word;


function Year100(dD:TDateTime):Word;


Types


TExpandWhere=(ewLeft,ewRight,ewBoth);

TIntBase=(ibDec,ibOct,ibHex);

TLimitType=(ltNone,ltDown,ltUp,ltBoth);

TScanTokenState=(stsInToken,stsInTokenSep);

TSetOfSymbols=set of Char

Constants

CAddSign = '+'

True,Yes,Da,On,1

CAskDeleteRecord = 'Delete record'

CCodeKey = #243+#43+#54+#4+#86+#12+#33+#45

cEmpty = ' '+ ' '+ ' '+ ' '+ ' '+ ' '+ ' '

CFZero = 1e-16

CIntBaseBINSet = ['0','1']

CIntBaseBINStr = '01'

CIntBaseDECSet = ['0'..'9']

CIntBaseDECStr = '0123456789'

CIntBaseHEXSet = ['0'..'9','A'..'F']

CIntBaseHEXStr = '0123456789ABCDEF'

CIntBaseOCTSet = ['0'..'7']

CIntBaseOCTStr = '01234567'

CMsgCannotDelete = 'Cannot delete record'

CMsgErrBadFilename = 'Invalid file name'

CMsgErrDCBCreate = 'Error in initialization string'

CMsgErrFileCreate = 'Error creating file [%s]'

CMsgErrPortOpen = 'Error opening port [%s]'

CMsgFormNoExists = 'Form does not exist in EXE!'

cNull = ''

CResAbout = 400

CResBeSmart = 100

CResInitMsg = 630

CResInitMsgForm = 632

CResStartTitle = 631

CResTableActionFail = 820

CResTitleAbout = 402

csAllCharacters = [#32..#255]

csAlnum = ['a'..'z','A'..'Z','0'..'9']

csDirectoryRange = ['A'..'Z','a'..'z','0'..'9','\',':']

csMaskRange = ['A'..'Z','a'..'z','0'..'9','*','?','.']

csNormalFileRange = ['A'..'Z','a'..'z','0'..'9','.','_']

csNumAlpha = ['a'..'z','A'..'Z','0'..'9','š','Š','ž','Ž','è','È','æ','Æ','ð','Ð']

csOnOff = ('No','Yes')

cstrFalse = 'N'

CStrNotAvail = 'N/A'

cstrTrue = 'D'

CSubSign = '-'

csYesNo = ['Y','y','N','n']

CTrue = ['T','t','Y','y','D','d','O','1']

CVerMajor = '3'

CVerMinor = '0'


Variables