------------------------------------------------------------------------

TDynArray For Delphi 16/32 - Overview

A dynamic array is an array that changes size at runtime, similar to a
TStrings object.  The TDynArray class is an object that will maintain
a dynamic array in Delphi 1 or 2 for you.  Anyone who has used a dynamic
array in the past will appreciate using the new class.. and anyone too
scared to try a dynamic array on their own can get over their anxiety.

By following a few simple steps listed below, you can easily create and
manipulate a dynamic array with much greater control than a normal array.

The TDynArray allows you to easily:

-ADD            elements to the array
-DELETE         elements from the array
-INSERT         elements into the array
-SHIFT          elements around the the array
-SWAP           elements in the array
-SORT           the entire array by any element, even inside a record!
-SAVE           an array to a file
-LOAD           an array from a file
-SAVETOSTREAM   an array to a stream
-LOADFROMSTREAM an array from a stream


Also, built in is a set of custom exceptions that allow your program to handle
errors without causing a GPF common to improperly using a dynamic array.

The DynArray allows arrays of any data type, including records.  You can
also sort the array by any field in a record, including PChars and Strings!

------------------------------------------------------------------------
Dynarray is a non-visual class that does not need to be installed to your
Delphi component library.  Simply copy DYNARRAY.DCU to your DELPHI\LIB
directory, or anywhere else along your library search path.
------------------------------------------------------------------------

TDynArray - Properties and Methods

 constructor Create  ( ItemSize : Longint );
 function    Add     ( ItemPtr: Pointer ) : Pointer;
 function    Delete  ( Index : Longint ) : Pointer;
 function    Insert  ( Index: Longint; ItemPtr: Pointer ) : Pointer;
 function    Shift   ( Index1, Index2: Longint) : Pointer;
 function    Swap    ( Index1, Index2: Longint) : Pointer;

 function    Sort    ( offset : Word; dattype : String ) : Pointer;
 { Sort DatType: 'string', 'pchar', 'shortint', 'byte', 'char'  
                 'smallint', 'word', 'longint', 'single', 'double'  }

 function    SaveToFile   ( filename : String ) : Pointer;
 function    LoadFromFile ( filename : String ) : Pointer;
 function    SaveToStream  ( Stream : TStream ) : Pointer;
 function    LoadFromStream( Stream : TStream ) : Pointer;

 property Count     : Longint        {contains number of elements}
 property Size      : Longint        {size in bytes of the array}

------------------------------------------------------------------------

How to create a dynamic array using TDynArray:


	uses    DynArray;          {Don't forget}

	type
		TMyArrayType = array[0..32760] of smallint;

	{First, declare an array TYPE of the maximum array size
         possible. It must be smaller than 64K (65520 bytes).
	 Smallint can be any data type or a record type.}

	var
		MyArray		 : ^TMyArrayType;
		DynArray1 	 : TDynArray;


	{Next, declare a pointer to the array type. Also, declare
	 an instance of a TDynArray.}

	procedure FormCreate  {or anywhere else you want to do it}
	begin
		DynArray1:= TDynArray.Create( sizeof(smallint) );

		{When creating the DynArray, you must send the
		 size of the data type or record.  (Use sizeof) }

	end;

	procedure AddtoArray
	begin
		MyArray:= DynArray1.AddItem( 150 );

		{Add the number 150 to next array position}
	end;


	procedure AccessArray
	Var MyInt : smallint;
	begin
                MyInt:= MyArray^[ 0 ];  {access an existing element}

		{MyInt would contain the number 150}
	end;

	procedure DestroyArray
	begin
		DynArray1.Free;
	end;

------------------------------------------------------------------------
Version 2.5a Includes a new file:  DYNTYPES.PAS

DynTypes are a set of pre-initialized dynarrays of all popular
Delphi data types.  Once created, they can be used just like a
standard dynarray, however the array is contained INSIDE the object!
We are still working on help files for both dynarrays.  If you need
assistance, send email to: dan@realsoftdev.com

------------------------------------------------------------------------

This unregistered version will work in the Delphi IDE only.  When
you register, you will recieve the complete source.

To Order on Compuserve for only $10.00 U.S., GO SWREG # 12661

------------------------------------------------------------------------
