Delphi 2.0 Utility Extensions
-----------------------------

This unit comprises many of the functions and procedures 
which many Delphi developers have had to write for themselves.  
These are the types of utilities that you would have expected 
to round out Delphi's function set but, for whatever reason, 
are absent.

In our use of Delphi we have developed this set of tools as a
standard unit for nearly every application written, and thought
that there must be others, like us, who's code-lives could be
simplified by the publishing of just such a unit.

Enjoy!


Definitions:
------------

The included functions and their definitions are:

Function BuffZero(Num, Len: Word): String;
Function CopyStream(InStream, OutStream: TStream): Boolean;
Function BoolToStr(Val: Boolean): String;
Function StrToBool(Val: String): Boolean;
Function BoolToInt(Val: Boolean): Integer;
Function IntToBool(Val: Integer): Boolean;
Function HexToInt(Val: String): Integer;
Procedure DelTree(RootDir: String);
Procedure ParseString(Line, Separator: String; UseParenths: Boolean; RetList: TStrings);
Function BackSlash(Line: String): String;
Function Pwr(X, Y: Integer): Integer;
Function TimeStr(Time: TDateTime; Config: Byte): String;
Procedure TimeDiff(Time1, Time2: TDateTime; var Yr, Wk, Da, Hr, Min, Sec: Word);
Function WindowsDirectory: String;
Function ProgramDirectory: String;

Details about each of these functions is included later in this document.


Registration:
-------------

These tools are provided as shareware.  As such, if you use them you are required to
register them.  There is a time-bomb which will cause them to stop working 30 days
from the time of their first use.  At this time, a dialog box will inform you that
the trial period has expired.  We are not normally in the business of providing 
these types of products, and would like to make the distribution a worth-while
venture.  That being the case, we are asking a very small amount for the use
of them.  They represent hours of work by our development team, and are the result
of many months of finding (and covering) the holes in Delphi, and feel this fee
is mearly a token of that effort.

Registration entitles you to unlimited, royalty-free distribution rights in your 
applications.  You may not, however, redistribute them without the express written
consent of I Write Software.

To register, please print and fill out the "REGISTER.TXT" and send it along with
a check for $5.00 (US) to:

I Write Software
4838 Manitoba Rd.
Columbus, OH 43229

At this time we can only accept payment in the form of a check.  You have the
option of receiving the registered version via US Post or e-mail.  Please indicate
your choice on the registration form.



THE FUNCTION SET:
-----------------

+
  Function BuffZero(Num, Len: Word): String;

BuffZero will take a number and fill in the leading spaces with zeros to make a
  string of length Len.  

ex:
  S := BuffZero(37, 4); //will return '0037' to S

+
  Function CopyStream(InStream, OutStream: TStream): Boolean;

CopyStream will copy a stream object from InStream to OutStream.  The copying
begins with the current position on InStream and continues to the end of the
stream.  The position of both streams will be the end of the stream.  You will
need to take care of any necessary positioning before the copy.

+
  Function BoolToStr(Val: Boolean): String;

BoolToStr Converts a boolean value to its string equivalent.  So, passing False will
return 'False', and True will return 'True'.


+
  Function StrToBool(Val: String): Boolean;

StrToBool converts a string to its boolean equivalent.  So, passing 'True' will
return True, and 'False' will return False.  The string evaluation is not case-
sensitive and ignores leading and trailing spaces.  Passing anything other than 
the expected strings will return False.


+
  Function BoolToInt(Val: Boolean): Integer;

BoolToInt returns the integer value of the boolean variable.  True will return
1 and False will return 0.  


+
  Function IntToBool(Val: Integer): Boolean;

IntToBool will return the Boolean equivalent of the integer.  0 will return False,
everything alse will return True.


+
  Function HexToInt(Val: String): Integer;

HexToInt:  Delphi provides the function IntToHex but, oddly, does not provide its
sister function "HexToInt".  This functions converts a hex number, in the form of 
a string, to its integer value.  Leading zeros are acceptable.  Invalid characters
in the hex number are treated as 0.


+
  Procedure DelTree(RootDir: String);

Deltree will attempt delete the directory RootDir and all of its contents.  This is
the equivalent of the DOS DelTree command.  THIS IS VERY DANGEROUS, SO BE CAREFUL!!
We can only warn you, but assume no responsibility for its results!


+
  Procedure ParseString(Line, Separator: String; UseParenths: Boolean; RetList: TStrings);

ParseString will take Line and break it into its individual units seperated by
Seperator.  The units will be returns into RetList in order of their occurance in
the original string.  If you pass UseParenths as True, it will not break apart
strings within parentheses, French-brackets, square-brackets, or quotes.

ex:
  ParseString('This is my, test, program', ',', False, MyList);
  // will return into MyList:
  // [0]  'This is my'
  // [1]  ' test'
  // [2]  ' program'

ex:
  ParseString('This is (my, )test, program', ',', True, MyList);
  // will return into MyList:
  // [0]  'This is (my, )test'
  // [1]  ' program'


+
  Function BackSlash(Line: String): String;

BackSlash formats a directory string by making sure it ends with '\'.


+
  Function Pwr(X, Y: Integer): Integer;

Pwr raises X to the Yth power.


+
  Function TimeStr(Time: TDateTime; Config: Byte): String;

TimeStr formats a time into its respective number Days, Hours, Minutes, and
Seconds.  Config is a bitmapped flag which indicates which items to include.

ex:
  S := TimeStr(Now - MyStartTime, 15);  // Returns Days:Hours:Minutes:Seconds
  S := TimeStr(Now - MyStartTime, 7);  // Return2 Hours:Minutes:Seconds
  S := TimeStr(Now - MyStartTime, 3);  // Return Minutes:Seconds
  S := TimeStr(Now - MyStartTime, 1);  // Return2 Seconds


+
  Procedure TimeDiff(Time1, Time2: TDateTime; var Yr, Wk, Da, Hr, Min, Sec: Word);

TimeDiff returns the difference between Time1 and Time2 in terms of Years, Weeks,
Days, Minutes, and Seconds.


+
  Function WindowsDirectory: String;

WindowsDirectory returns the Windows installation directory.  This function
simply encapsulates the GetWindowsDirectory API call.


+
  Function ProgramDirectory: String;

ProgramDirectory returns the directory from which the application was executed.


Bugs, Questions, Suggestions, Etc.:
-----------------------------------

Please report any bugs to bugs@iwsoft.usa.com.  Please include as much 
information as possible.

If you have any questions, or suggestions for additional tools, please
send them to support@iwsoft.usa.com.  We are always looking to improve
our products, and will reward good suggestions.

Thanks for your support!

The IWSoft Development Team.

