VFPDosPrint Quick Guide
(for more detailed help, see file dosprinten.chm included in the release package)
The fastest way to start using VFPDosPrint
is using format files. All you will need is:
- A format file that contains the report design
- A dataset to be used to generate the report
Let's say we have a Customer table with the following columns:
Now, we need to create a format file to generate a simple listing report. Create a text file with the following text. Once done, save the file with the name 'CUSTOMERS.FMT':
# Basic customer report
StartConfString=$C10$$COFF$ // 10 CPI not condensed (80 cols)
PaperLenght=60 // This will cause a page eject every 60 lines
TopMargin=2 // Print 2 empty lines at the start of every new page
LeftMargin=5 // Append 5 spaces to every new line
# Macros are like report variables. They exists only in the scope of the
# report begin generated
# The FORMAT section is a quick way to declare the different bands
# of the report, like HEADER, DETAIL and FOOTER.
# pageno and datetime are internal macros that are generated automatically.
he: [COMPNAME ] CUSTOMER LIST
he: ID FULL NAME ADDRESS PHONE # BALANCE
he: ======= ======================= ===================== ============= ============
de: [XCID ] [PROPER(CustName) ] [CustAddress ] [CustPhone ] [XCustBal ]
fo: [datetime ] %pageno%
Before proceed with the next step, lets take a closer look of this format file. First, note that everything is contained in sections wich starts with < > and ends with </ >. Each section has a defined purpose inside the format:
configures page size and margins, as well as specific printer configurations.
define report-level variables (called Macros), that are used in other sections across the format.
define the layout of the report.
Everything enclosed with '
' or '% %' delimiters are
. This expressions will be evaluated and the result inserted in the text in the same position of the expanded expression. Finally, any line starting with
will be considered as a comment and will not be sent to the final report, as well as any empty line or text that is not enclosed inside a section.
Now, we are ready to generate our text report. All we need now is a data set and an instance of DOSPrint class:
*-- Generating customer report
SET PROCEDURE TO vdp ADDITIVE
oDP.Run() && Automatically uses the current alias as the report's dataset
At this time, we have our report generated and ready to be printed. Yes, is THAT
easy. You can either send the report to a defined printer or save it to a file:
oDP.Print( GETPRINTER() ) && Send report to a selected printer
oDP.PrintToFile( GETFILE() ) && Save report to a disk file
This is a basic example of what can be done using VFPDosPrint
. Please, read carefully the help file included in the release package to learn how you can use VFPDosPrint to generate really complex text-based reports or even structured files like HTML
IMPORTANT NOTE ABOUT THE HELP FILE
VFPDosPrint is the open source version of a commercial product called DP
. Although I changed all references to DP in the source code to VFPDosPrint and remove the licensing restrictions, the help files are still the original ones and, therefore, they refers to
and not VFPDosPrint. This will be fixed in the near future, so I apologize for the confusion in the mean time.