Giter Site home page Giter Site logo

vfpdosprint's Introduction

VFPDosPrint

Generate text-based reports that can take full advantage of dot-matrix printer capabilities

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:

  • CustID
  • CustName
  • CustAddress
  • CustPhone
  • CustBalance

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':

# CUSTOMERS.FMT
# Basic customer report
#
<config>
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         
</config>

# Macros are like report variables. They exists only in the scope of the
# report begin generated
#
<macros>
COMPNAME='XYZ Bookstore'
COMPADDRESS='Caracas, Venezuela'
XCID=CustID
XCustBal=TRANSFORM(CustBalance,'9,999,999.99')
</macros>

# 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.
#
<format>
#   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8
he: [COMPNAME                         ]                                CUSTOMER LIST
he: %COMPADDRESS%
he: 
he: ID      FULL NAME               ADDRESS               PHONE #            BALANCE
he: ======= ======================= ===================== ============= ============
de: [XCID ] [PROPER(CustName)     ] [CustAddress        ] [CustPhone  ] [XCustBal  ]
fo: 
fo: 
fo: [datetime           ]                                                   %pageno%
</format>

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:

config: configures page size and margins, as well as specific printer configurations.

macros: define report-level variables (called Macros), that are used in other sections across the format.

format: define the layout of the report.

Everything enclosed with ' ' or '% %' delimiters are expandible expressions. 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 VFPDOSPrint class:

*-- Generating customer report
*
SELECT 0
USE CUSTOMERS
GO TOP

LOCAL oDP
SET PROCEDURE TO vdp ADDITIVE
oDP=CREATEOBJECT("VFPDosPrint")
oDP.PrintFormat="CUSTOMERS.FMT"
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 or XML!.

IMPORTANT NOTE ABOUT THE HELP FILE

VFPDosPrint is the open source version of a commercial product called DP or DOSPrint. 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 DP and not VFPDosPrint. This will be fixed in the near future, so I apologize for the confusion in the mean time.

Victor Espina

vfpdosprint's People

Contributors

vespina avatar doughennig avatar

Watchers

James Cloos avatar Tester avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.