Copyright: Copyright ©1995


class_TReportManager
 TReportManager Component

properties	exceptions

Author

  Bill White

  3117 Raymond Drive

  Atlanta, GA 30340

  (404)457-5348

  Compuserve Address:  73612.3477

Unit

  RptMan

Version Info

This is version 1.0 of the TReportManager.

Description

Use this component in conjunction with the TModifiedReport component to provide a level of abstraction for running reports, from Delphi, with ReportSmith.  The TModifiedReport is analgous to the TDatabase component.  While a single Database component provides an indirect reference to a path where data tables can be found, a single TReportManager component provides an indirect reference to a path where reports can be found.  Currently, using TReport components, you have to specify the ReportDir property for each of your TReport components.  This isn't very flexible because there is never any guarantee that your users are going to have their system setup just like yours.  Consider this example:  you are designing a system for your users and your users have the option of running a report.  So when you are designing the system, you set the ReportDir property of all your TReport components to c:\app\reports.  When you go to install your system, your users decide that they want your program on the D-drive.  Now you have to go back to your office, change the ReportDir property for of ALL of the TReport components, re-compile it, and then go back over to your users office.  This is even worse if you are writing software for general consumption.  Very fustrating indeed!  In essence, the TModifiedReport-TReportManager connection is just the TTable-TDatabase connection;  just as your TTable components do not have to know anything about where the physical data tables are, your TModifiedReport components do not have to know anything about where your reports are physically located.

If you want to hard-code a directory for TReportManager to use, you always have that option.  To do this, simply specify a directory for the Directory property.  However, I recommend that you go with the extra layer of abstraction by providing a file that the TReportManager will use to find the path.  (Note:  this is sort of like the BDE for reports).  To do this, you must specify a filename in the ININame property.  For more information on the format  of this file see INI File Format For TReportManager.

The ReportDirectory property will hold the directory that your reports are in, at run-time.  You can obtain a list of the file groups, at run-time, that are in the file specified by the ININame property with the Groups property.

If you are using the TInstall component to install your programs and you specify a filename for the ININame property, then a file gets written automatically that TReportManager can read.


TReportManager_PropertiesPopup

Properties

Directory

FileGroup

Groups

ININame

ReportDirectory


prop_TReportManagerDirectory
Directory Property

Applies To

TReportManager

Declaration

property Directory: String;

Description

The Directory property allows you to specified a hard-code directory in which the TReportManager component will find reports.  I recommend using the ININame property instead.


prop_TReportManagerFileGroup
FileGroup Property

Applies To

TReportManager

Declaration

property FileGroup: String;

Description

The FileGroup property specifies which file group, in the file specified by the ININame property, to use.  E.g. each file group has an associated directory and the TReportManager component will return the filegroup's associated directory as the directory where reports will be found.  For information on the format of this file see INI File Format For TReportManager.


prop_TReportManagerININame
ININame Property

Applies To

TReportManager

Declaration

property ININame: String;

Description

The ININame property tells the TReportManager component where to find a listing of the file groups and file group directories.  For information on the format of this file see INI File Format For TReportManager.  If you specify a full path for ININame, then the TReportManager will look for the file in that path.  If you do not specify a full path, but just a name, for ININame, then TReportManager will look in the current directory for the file.  I recommend using the last method.  Of course, if you do this, then you have to make sure that the file is in the same directory as your executable. If you are using the TInstall component to install your programs and you specify a filename for the ININame property, then this file gets written automatically!


TReportManager_ExceptionsPopup

Exceptions

EErrorReadingINI

ENoSuchFileGroup

EReportDirectoryUndefined


Exception_TReportManagerENoSuchFileGroup
ENoSuchFileGroup Property

Applies To

TReportManager

Declaration

ENoSuchFileGroup = class(Exception);

Description

The ENoSuchFileGroup exception is raised if the TReportManager component cannot find the filegroup specified in the FileGroup property in the file specified by the ININame property.


Exception_TReportManagerReportDirectoryUndefined
EReportDirectoryUndefined Exception

Applies To

TReportManager

Declaration

EReportDirectoryUndefined = class(Exception);

Description

The EReportDirectoryUndefined exception is raised if the ReportDirectory property equates to zero at run-time.


Exception_TReportManagerEErrorReadingINI
EErrorReadingINI Exception

Applies To

TReportManager

Declaration

EErrorReadingINI = class(Exception);

Description

The EErrorReadingINI exception is raised if the TReportManager component has trouble reading the file specified in the ININame property.


prop_TReportManagerGroups
Groups Property

Applies To

TReportManager

Declaration

property Groups: TStrings;

Description

Run-time only.  The Groups property simply returns a list of all the group names in file specified by the ININame property.


prop_TReportManagerReportDirectory
ReportDirectory Property

Applies To

TReportManager

Declaration

property ReportDirectory: String;

Description

Run-time only.  The ReportDirectory property is the directory in which your reports are found.  If you have specified a value for the Directory property, then that directory will be found.  If you have specified values for both the FileGroup property and the ININame property, then ReportDirectory will return the directory for the file group that is specified in the file (specified by the ININame property).  For more information on the format of this file see INI File Format For TReportManager.


INI File Format For TReportManager

The file you use must contain, but is not limited to (see sample #3), the following information; It can have anything other information that your program needs.  If you are using the TInstall component to install your programs and you specify a filename for the ININame property, then this file gets written automatically.  Note that sample #1 has one file group, specifically Reports1 and sample #2 has three file groups, specifically Finance, Commerce, and Industry.  If you specify one of the file groups for the FileGroup property, then when the run method of any of your TModifiedReport components is called, its associated TReportManager component looks up the directory in this file and passes it to the TModifiedReport.

For example, Assume you have a file, named 'myapp.ini' that has the same format as in sample #1, in the same directory as your executable.  If you specify 'myapp.ini' for the ININame property and Reports1 as the value for the FileGroup property, then the ReportDirectory property will be 'c:\myapp\reports1'.  Also, if you have any TModifiedReport components hooked to this TReportManager, when their run method is called, the ReportDir property will be changed to 'c:\myapp\reports1' and ReportSmith will run the report, specified by ReportName, in this directory.

Sample formats:

{ The following is sample #1: the file does NOT contain this line }

[FileGroups]

GroupNames=Reports1

[Reports1]

Directory=c:\myapp\reports1

{ The following is sample #2: the file does NOT contain this line }

[FileGroups]

GroupNames=Finance,Commerce,Industry,

[Finance]

Directory=c:\myapp\finance

[Commerce]

Directory=c:\myapp\commerce

[Industry]

Directory=c:\myapp\industry

{ The following is sample #3: the file does NOT contain this line }

[MyProgramInfo]

Directory=c:\myapp

UserName=Bill

Version=1.0

Copyright=1995

[Miscellaneous]

Description=This is my application

[FileGroups]

GroupNames=Reports1

[Reports1]

Directory=c:\myapp\reports1