
Distributing Report and Label Files
Reports and labels can be included in your project and built into your application (.exe or .app file), or they can be delivered separately on disk.
Tip |
|---|
| You can reference reports and labels in your application project, for easy reference while designing the application, without building the report and label files into the compiled application file. For more information, see How to: Exclude Files from Builds. |
Which strategy you decide to use usually depends on whether you want end-users to have the ability to adjust the reports and labels. If the reports and labels are on disk as separate files, your application can provide facilities for end-users to customize them, using the MODIFY REPORT and MODIFY LABEL commands.
You can use a combination approach, building the reports and labels into your application to serve as read-only output templates, but copying them to disk for end-users' modifications. This approach has the advantage of ensuring that you can revert to a "clean" copy of the original report or label definition file when necessary.
Tip |
|---|
| Using a built-in template also allows you to make some last-minute adjustments to the report or label before an end-user design session. For example, you could adjust protection flags in the editable copy using an application lookup table for user permissions. You might also replace the ToolTips for report controls you use for development purposes, with developer notes, for another set containing end-user instructions. Because you can add extension fields to report and label tables, this programmatic run-time adjustment would be as simple as opening the report or label table with the USE command, followed by a command such as REPLACE ALL ORDER WITH <your extension field>. For more information, see Understanding and Extending Report Structure. |
Under some circumstances, Visual FoxPro permits the commands MODIFY REPORT and MODIFY LABEL to be used with the names of read-only report and label files built into the application. When the application's end-user saves the report or label from the designer, Visual FoxPro saves the copy to disk. For this strategy to work, the report and label files must either be in the same folder as the project (.pjx) file or in a folder whose name Visual FoxPro can resolve at run time, relative to the application file (.exe or .app).
For example, suppose your project is in a folder named d:\app and the report form you wish to include is d:\app\reports\my.frx on your development computer. At run time, you install the application file (.exe) to c:\programs\myapp. If you create a reports subfolder, c:\programs\myapp\reports, you can use the command MODIFY REPORT my.frx. When the user chooses to save the report, Visual FoxPro saves the report as c:\programs\myapp\reports\my.frx by default. However, if c:\programs\myapp does not have the subfolder, an error occurs on the MODIFY REPORT command.
You can verify the availability of the subfolder at run time, and use the MD | MKDIR Command if necessary. Alternatively, use the following commands, where lcDir holds the name of a target folder you have previously verified with the user.
SELECT * FROM my.frx INTO TABLE (lcDir + "my.frx")
MODIFY REPORT(lcDir + "my.frx")
This approach puts the process completely under your control. It allows you to configure the target folder to meet the user's needs rather than the project's design-time structure.
Note |
|---|
| When distributing reports, whether built-in or as external files, ensure that all additional required files are available to your application at run time. For example, if your report references an image file, include the image file in your application or distribute the file as a separate file on disk. Ensure that the image file is in the same location in your project's build structure, or in the folder structure of your distributed application on disk, relative to the report file, as it was when you designed the report. Otherwise, Visual FoxPro cannot find the image file when it generates the report. If you choose to build reports into your application, other compiled modules, such as ReportOutput.app or ReportBuilder.app, may not be able to locate the files within your compiled module. You can ensure that the report system components find your files by building in their source files to your application, rather than distributing them as separate applications. The next section discusses your options for distributing these components. |