home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
scr2frg.zip
/
SCR2FRG.DOC
< prev
next >
Wrap
Text File
|
1990-05-14
|
12KB
|
260 lines
This article is reprinted from the March 1990 edition of
TechNotes/dBASE IV Due to the limitations of this media, certain
graphic elements such as screen shots, illustrations and some tables
have been omitted. Where possible, reference to such items has been
deleted. As a result, continuity may be compromised.
TechNotes is a monthly publication from the Ashton-Tate Software
Support Center. For subscription information, call 213-538-6060.
====================================================================
What Were Once Screens
Are Now Reports
---------------
Copy of the March 1990 issue Ashton-Tate's Technotes magazine
By BRYAN FLYNN
Editors Note:
Since this article discusses the use of .GEN files and Template
Language, you will need the Template Language compiler and
documentation which is included only with the Developer's
Edition of dBASE IV. For those with the standard edition, you
may take advantage of this new .GEN file, Scr2Frg.GEN, which
creates reports from existing screen forms without the need for
programming, by accessing the Ashton-Tate Bulletin Board,
CompuServe, or GEnie.
One of the strengths of dBASE IV is the
What-You-See-Is-What-You-Get (WYSIWYG) approach of creating
Reports (.FRM files) and Screen Forms (.SCR files). Many times,
a report that duplicates a screen form is needed. For instance,
a hard copy of a data entry record is a typical example.
There are three ways to create a report from a screen form. One
way is to create a report that looks exactly like your screen
form. However, if your screen form is fairly complex, this
could be a redundant, time consuming affair. Another way is to
incorporate a copy of the .FMT code created when you saved your
screen form into a program. This requires programming knowledge
which could find you spending more time converting and less time
producing results.
You might ponder, "Wouldn't it be nice if dBASE IV did this for
me automatically?" Since the layout is already there, why
can't dBASE IV do it? Well, good news! It can! That's the
third and most desirable solution and the point of this article.
The easy solution to the above problem is to have a dBASE IV
template do the work for us. The template source code presented
at the end of this article will take an existing screen form
(.SCR) and generate a report form file (.FRG). This report file
can then be used in conjunction with the REPORT FORM command or
run from the Control Center.
A Brief Explanation of the Template Language
The Template Language takes dBASE IV design files (in our case
the .SCR file) and generates either documentation or program
versions of these objects via the Template Language Compiler.
Other design sources include .FRM, .LBL, .BCH, .APP, .POP and
.BAR files.
Consider each design file as a stack of items. For example, a
screen form can contain a stack of items consisting of fields,
boxes, text, memory variables, and calculated fields. Each of
these items have certain attributes such as row and column
position, display length, data type, and other specific
attributes. Attribute descriptions of these items are kept in
definition files (.DEF files). The definition file for screen
forms is called FORM.DEF.
The Template Language enables you to retrieve items from these
design files, examine them, and generate code depending upon the
items examined. When you create a screen form, dBASE IV
retrieves the stack of items contained in the .SCR file, passes
it through FORM.GEN and generates a .FMT file (called a format
file).
The Template Language contains tools, consisting of control
structures, file handling capabilities, and functions to scan
through a design file and determine what is outputted. These
tools are used to create Template Language programs. The source
code for Template Language programs are kept in .COD files.
These .COD files are then compiled into .GEN files. Using
Template Language, you can create your own custom made .GEN files
and control the dBASE IV code outputted when generating labels,
reports, APGEN Applications, and Screen Forms.
There are a number of existing .COD files in your DTL directory
that can be used freely as examples or building blocks for your
own .COD files. If you haven't installed them, check the
contents of your Template Language disks.
There are two basic steps to creating a .GEN file:
1. Write the source code (.COD file) for the .GEN file using
a text editor
2. Compile the .COD file into a .GEN file using the DTC.EXE
program. dBASE IV uses these default template names to
create the related code and object files for the
following:
*Labels: LABEL.GEN
*Reports: REPORT.GEN
* AppsGen: MENU.GEN
*Screens: FORM.GEN
The .COD files that generated these files are called LABEL.COD,
REPORT.COD, AS_MENU.COD and FORM.COD respectively.
Please note that any existing report file with the same name as
your screen form will be overwritten. If you have an existing
report with the same name as your screen, it is important to
first copy your .SCR file to a new name so that it will not
conflict with the similarly named report.
A more complete explanation of the Template Language can be found
in the Developer's Edition manual entitled Using the Template
Language.
How to use Scr2Frg.GEN
Begin by either typing in the listed template code at the end of
this article or retrieving it from the Ashton-Tate Electronic
Bulletin Board. Compile it by entering at the DOS prompt:
DTC -iScr2Frg.COD
DTC.EXE is the Template Compiler which comes with the dBASE IV
Developer's Edition.
The "-i" parameter prefaces the file being submitted to the
compiler, indicating it as the input file. Once Scr2Frg.COD is
successfully compiled, a file named Scr2Frg.GEN will exist.
Copy the .GEN file (Scr2Frg.GEN) into your dBASE IV directory, if
it doesn't already reside there.
You're now ready to generate a new .FRG file from an existing
screen form. At the DOS prompt enter:
SET DTL_FORM=Scr2Frg.GEN
This specifies dBASE IV to use the Scr2Frg.GEN file instead of
the default FORM.GEN. Now go into dBASE IV and modify the
screen form from which you want to create a report. Once you're
in the layout screen, press Ctrl-End. This will force
regeneration of your design screen and create a new .FRG file by
the same name as that screen.
It is important that the SET DTL command, which sets a DOS
environmental variable, not be executed while in a DOS access of
a dBASE IV session. A DOS access is a copy of the environment
and not a return to the original DOS environment which exists
before and after a dBASE IV session. Therefore, any SET command
would be eliminated upon the return to dBASE IV via the DOS
access.
Points to consider
If the screen you're regenerating does not have an existing .FMT
file, the error message "File could not be found" will appear.
The error appears because dBASE IV tries to compile a .FMT file
any time you save a screen. If one doesn't exist, the above
error message appears which may be ignored.
After generation, you can then run the .FRG file from either the
Control Center or the dot prompt as if it were a regular
report. If you want to place the new report in the Control
Center, you must first run the report initially from the dot
prompt. The reason for this is that the Control Center will
only let you add .FRM or .FRO (the interface and object) files
and the Scr2Frg.GEN template file creates only a .FRG (program
code) file. Running the report with the REPORT FORM command
will automatically create a .FMO file.
One point that may not be obvious to newer users is that no
design file (.FRM) is created. The report you create using the
Scr2Frg.GEN file cannot be modified via MODIFY REPORT since the
initial design data was from the screen form.
Scr2Frg.COD Usage Notes
* Scr2Frg will create a report that looks exactly like your
screen (except for the status bar). This also includes
memos in windows looking exactly the same.
* After each record, a page eject will occur.
* A screen will always take up a minimum of either 25 or 43
lines depending upon what display mode dBASE IV was in
when the screen report was generated. Consequently, even
a screen with one line of information will generate 25
to 43 lines when printed.
* If you would like to print more than one screen per
page, you'll need to adjust the system memory variables
_plength and _padvance. _plength specifies your page
length and _padvance specifies whether to advance the
paper with either line feeds or a form feed.
Example: Your screen is 25 lines in length and your
physical page length is 66 lines. To place two screens
per page, set plength to 33 and _padvance to "Linefeeds"
(instead of the default "Formfeed"). This will place
one screen for each 33 lines.
These two variables can either be set from the dot
prompt, in a program, or from the Print menu. When
setting these from the Print menu, page length would be
set under the Print: Page dimensions menu. The method
of advancing a page (formfeed vs. linefeeds) would be
set from the Print: Control of printer menu.
* The line number on which item numbers are placed when
creating a screen is respected. This means that an item
on the 26th line of a two screen screen form will print
on the 26th line of the report and not on a separate
page.
* A heading can be specified with the REPORT FORM command,
using the HEADING parameter, and will appear at the top
of each page. The number of lines in the heading will
be added on to the screen size. Suppose you have a three
line header and you're printing a 25 line screen. The
total number of lines needed to print each record would
then be 28.
* The PLAIN and SUMMARY options of the REPORT FORM command
are ignored except where PLAIN is included with the
HEADING option. These two options are mutually
exclusive with the PLAIN option taking precedence.
* An optional page break will be inserted on whatever line
desired if that line has .PB in the first column. This
feature could be helpful if, for instance, you have a
four page screen form and you'd like everything after a
certain line to appear on a new page. To use, simply
type .PB in the first column on the line you want to
begin the next page. The next time you regenerate your
screen with the Scr2Frg.GEN template active, a report
will be generated with a page break at that point. Do
not specify a page break while a box is printing as
defined boxes will not respect a page break.
* When finished generating reports from screen forms by
using Scr2Frg.GEN, make sure to set your form template
back to its default. This is done by entering at the DOS
prompt:
SET DTL_FORM=
Since nothing is specified after the equal sign, DTL_FORM is
erased from memory and the default FORM.GEN will now be assumed.
The Scr2Frg.GEN file is just one example of how a feature can be
added to the product simply by using the appropriate template
and represents a very useful flexibility of dBASE IV. Remember
that custom made templates can be as simple or complex as you
wish and while it might take some time to write a template, the
time saved in developing a system or the added flexibility to a
system could more than compensate.