TCreateTempFile - Copyright 1995, Vision Software

TCreateTempFile is designed to facilitate easy creation of temporary
files for use throughout an application.   With this component, you can
create temporary data base tables, audit logs, or anything else that you
might need throughout the development process.  It will even automatically
delete the file set that was created when the parent form or application
is terminated.

This component is distributed as shareware.  If you use this component 
in your application, please remit $20 to:   

                       Vision Software
                       3910 Highway 45 North, Suite C, 
                       Meridian, MS 39301

If you prefer to use Amex, Visa, MasterCard, or Discover, call us at
601-485-6339 with your credit card information.

Commented source code is available for an additional $20.  

This license fee is per developer, not per end-user, so you can 
distribute your application without any royalties.

Enjoy!





The following properties are available to TCreateTempFile:


------------------------  Design Time Properties --------------------------------
FilePrefix:String 
Specify a file prefix here.  Whatever gets specified will be truncated to 
3 characters.  We typically use TMP which is the default.

ShowError:Boolean 
This component will display a rudimentary error message if this property
is true.  

CloseAfterCreate:Boolean 
If you want to write to the newly created file using low-level file functions,
then set this to false, and use the Filehandle property for your subsequent
low-level calls.

DeleteOnFree:Boolean 
By default this control will delete all temporary files that it has created
when the application terminates, or the form that contains this component is 
freed.  Set to False to leave the temp files alone for manual deletion later.

Location:TDir 
This property controls where the temporary files get created.  The possible 
values are:  ApplicationDirectory, WindowsDirectory, UserForcedLocation

ForcedLocation:String 
If the Location property is set to UserForcedLocation, then the value of this
property should be a fully qualified existing directory name.

Extensions:TStringList 
Define your list of file extensions here.  If you want to create unique files
for a database file, memo, and associated index, then create a line in this 
stringlist for each type of file needed.  (i.e. .DBT, .MDX, .DBF)

DebugMode:Boolean 
Set this to true to force a static file name for debugging purposes.

DebugFile:String 
Static file name to use for file creation if debug mode is true.  Do not put 
an extension here... the extension list will be used.

-------------------------  Events  --------------------------------
OnError:TNotifyEvent
If an error occurs, this event will be called, then the built in error message
will be displayed.  If you don't want the built in message displayed, then set
ShowError to False.

OnFree:TNotifyEvent 
This event is called when the control is freed to do any last minute cleanup
if needed.



-------------------------  Run Time Properties --------------------------------
AllTempFilesCreated:TStringList 
A list of all files created since the component was instantiated.

LastTempFilesCreated:TStringList 
A list of all files created during the last call to the Exec method.

FileHandle:Integer 
The DOS file handle for the LAST file created.

ErrorCode:Integer
The last DOS error code encountered.

ErrorMessage:String 
The last DOS error message encountered.

FullFileName:String 
The full file name, including path and extension of the last file created.

FileName:String 
The file name and extension of the last file created.

FileWithoutExt:String 
The file name without extension of the last file created.

FullFileWithoutExt:String 
The full file name, including path, without extension of the last file created.

FilePath:String 
The file path of the last file created.


----------------------------------  Methods -----------------------------------
Exec
Executes that create temp file process, creating a temporary file for each 
extension specified in the extension list.

DeleteLastTemporaryFiles
Deletes the last set of temporary files created.  If DeleteOnFree is True,
then this will be done automatically when the component is destroyed.

DeleteAllTemporaryFiles;
Deletes all temporary files created since the component was instantiated.
If DeleteOnFree is True, then this will be done automatically when the 
component is destroyed.

----------------------------------  Example ----------------------------------
This example shows how to use TCreateTempFile to create a temporary dBase file.
Drop a TTable, TBitBtn and a TCreateTempFile on any form.

For the TTable1, you shouldn't have to set any properties.  

For the TCreateTempFile1, set the extension to '.DBF'

For the OnClick Event for TBitBtn1 add the following code:

        TCreateTempFile1.Exec;
	
        With TTable1 Do Begin
             DataBaseName:=TCreateTempFile1.FilePath;
             TableType:=ttDBase;
             TableName:=TCreateTempFile1.FileWithoutExt;

             FieldDefs.Clear;
             FieldDefs.Add('Name',ftString,20,false);
             FieldDefs.Add('Addr1',ftString,20,false);
             FieldDefs.Add('Addr2',ftString,20,false);
             FieldDefs.Add('City',ftString,15,false);
             FieldDefs.Add('State',ftString,2,false);
             FieldDefs.Add('Zip',ftString,10,false);
             CreateTable;
             Open;
         End;

        	     	
You now have a uniquely created temporary data file.  If 
this data file needed an associated memo file and index, 
then you would need to add the .DBT and .MDX extensions to 
the extension stringlist.

When you have more than one extension specified, all files
created will have the same primary filename (i.e. TMP12345.DBF, 
TMP12345.MDX, TMP12345.DBT)

It shouldn't be necessary to write code to delete these files
as they will automatically be deleted when the form is closed.
If you don't want the files deleted automatically, then make
sure that the DeleteOnFree property is set to False.

