• No results found

body image l*

In document DataFlex V2 Jul1984 pdf (Page 152-160)

NUMBER VENDNUM

INPUT "ENTER VENDOR NUMBER: " VENDNUM

MOVE VENDNUM TO INVT.VENDOR //Jump in here REPORT INVT BY INDEX.I

INDICATE SELECT AS INVT.VENDOR EQ VENDNUM

ENOT SELECTI RETURN END.OF.REPORT //jump out here SECTION BODY

----

body commands

----

REPORTEND

Since the selection section is executed for every record,

it

should be

kept as small and fast as possible. Any calculation or string

manipulation which can be accomplished outside the selection section

will improve speed. Expressions should be evaluated outside the

selection section,

if

possibÍe9 and the results represented in the

selection section as numeric variables. Numeric variables are faster than numeric WindOWSg and string manipulation commands in the

selection section have the greatest potential of all types of

operations to slow down execution. Calculations and string

manipulations can be done in the HEADER command sectiom any of the

SUBHEADER command sections, or entirely outside (prior tO) the report macrop as necessary.

It

is possible to make compound selections in reports, with various AND and OR relationships among the

criteria.

Refer to the section of

this manual on "Conditional Execution" for the

full

range of possi-

bilities.

The following AND example shows how all customers with balances over $1AOO AND amounts over 90 days due would be selected

(NINETY_0AYS_AGO is a date variable calculated by subtracting ninety from the run date before the selection section):

INDICATE SELECT AS INVOICE.DATE LT NINETY_DAYS_AG0 [SELECT] INDICATE SELECT AS CUST.BAL GT 1000

OR combinations can be established by inverting the SELECT indicator

with a NOT, as in the following example, which would report all customers with EITHER balances over $1AOO OR balances over 90 days

old:

INDICATE SELECT AS INVOICE.DATE LT NINETY_DAYS_AG0 [NOT SELECTJ INDICATE SELECT AS CUST.BAL GT 1000

The GROUP ANY/ALL AND/OR ANY/ALL

facilities

can also be utilized in

setting the SELECT indicator for your particular requirements, as

described in the section of this manual on indicators.

_———————"____"___

"___"""""

DataFlex 2.0 User's Manual REPORTING AND OUTPUT C-41

PAGE CONTROL

Page control is handled with three predefined variables:

PAGEFEED offers three way control of how the page eject will be

determined: -1 " single sheet; O = hardware formfeed; or ## =

linecounter where ## is the total number of lines per page (physical

page height from perforation to perforation). The command with no argument is interpreted as though its argument were O (FomFeed). PAGEEND contains the number of printable lines per page. The default

is 55. A value of zero (O) in this variable

will

cause continuous output with no page breaks. This is useful, for examp1e3 for output

to a data

file

from which

it

is not intended to print directly. LINECOUNT contains the number of lines output as of any given moment. There Is not normally occasion to manipulate or reset the value of

this variab1ep since

it

is used by the two others listed above. These variables are global to Dataflex. They may be used with any

kind of outputting, not exclusively under the REPORT macro. Use MOVE commands to put the desired values Into these variables for page

control immediately before the REPORT command.

This example illustrates operator-entered selections and page control:

C-42 REPORTING AND OUTPUT DataF1ex 2.0 User's Manual

/PROMPT

List NAMES from which STATE:

_

/HEADER

NAMES FROM STATE OF:

_

...NAME ..

...CITY...

/B0DY

l*

FORMAT PROMFT.I {CAPSL0CK} STRING TEMP I

ACCEPT PROMFT.I

//

get operator input

CLEARSCREEN QUTFILE 'CON:

'

//

output to the screen

OPEN LIST I

MOVE 22 TO PAGEEND

//

page length is # of lines on screen MOVE

-I

TO PAGEFEED

//

stop at the bottan of each screen REPORT LIST BY INDEX.I

II

REPORT command

INDICATE SELECT AS LIST.STATE EQ PROMPT.I SECTION HEADER

PRINT PRQMF'T.I

//

print state selection to heading OUTPUT HEADER

SECTION BODY

PRINT LIST.NANE

//

print data PRINT LIST.CITY

OUTPUT BODY REPORTEND

INPUT "PRESS RETURN TO CONTINUE" TEMP ABORT

OUTPUT DESTINATION

Unless directed elsewhere, the default output device for the REPORT macro is the system I-ST: device (printer). Output can be redirected

to any valid sequential system device or

file

by placing an argument on the operating system command line wheA the configuration is executed (FLEX report destination). This form of command can. of

courseg be included in menus for operator selection, with or without querying for filename or device input. A1ternat1ve1yp the output

device or

file

can be "hard coded" in the configuration on the QUTFILE command line fmmediate?y above the REPORT command line. Used in this way9

literal

destinations ("CON:

",

'NERGFILE", etc) must be embedded

in quotation marks. Arguments without quotes

will

be considered

string variables, which can be used to pass operator input in response

to query prompts at the beginning of the configuration. Legal

devices on most systtms include CON: (CRT screen), PUN: (often used

for modemsL (-ST: (the printer). and any legal filename.

""""""""""""====="==========="—~———————

""=======——————————————————

DataF1ex 2.0 User's Manual REPORTING AND OUTPUT C-43 ———————————— =—==———————~

OPERATOR ABORT

The REPORT macroG default mode of operation causes a report to abort

if

any key is

hit

by the operator while the report is executing. This

mode may be disabled entirely or modified to ask the operator a

confirming question when a key Is thus

hit.

To do this» provide a

substitute for the predefined subroutine called "RPT.KEYPRESS'4

optimally just before the REPORTEND command. The i1lustrat1ve

subroutine below would give the prompt "PRESS <ESC> TO ABORT, ANY OTHER KEY TO CONTINUE", and then, depending on which key was pressed, either resume execution at the predefined procedure "RPT.LOOP" or abort via the predefined procedure "END.OF.REPORT". (Pressing any key

other than ESCape actually would cause execution to resume.) EXAMPLE:

RETURN

//

Must be added after end of section commands RPT.KEYPRESS:

STRING PAUSEKEY

l

INPUT "PRESS <ESC> TO ABORT, ANY OTHER KEY TO CONTINUE" PAUSEKEY [KEY.ESCAPE] RETURN END.OF.REPORT

RETURN RPT.LOOP

This procedure should be located before the REPORTEND command, and

immediately after the end of the last group of section commands, The RETURN command shown above on the

first

line must be added explicitly

in the configuration in order to insert this procedure.

If

the predefined procedure END$0F$REPORT is used instead of END.0F.REP0RTg tota11ing and other terminating procedures would be

skipped. Use of this procedure would be appropriate to use in case of printer misfeed, ribbon breakage, or a similar mishap.

PAGE BREAKS

The REPORT macro automat1ca11y maintains the number of lines remaining on the current page in manory at all times while outputting.

It

will

handle things like number of lines required by a SUBTOTAL or BODY image automatically, and

if

allowed to operate in

its

default mode,

it

will

reprint headings and subheadings as required at the top of each new page.

If

you are doing "fancy" pagfng that requires direct

controb howevem you will have to provide commands within the appl1cab1e section(s) (typically the BODY). The PAGECHECK command checks whether the number of lines given in the command argument remains on the current page. The FORMFEED command sends a "raw" formfeed (that is,

it

does not print headings at the top of the new

page). The sequence [PAGEBREAK] GOSUB NEWPAGE utilizes the PAGEBREAK

predefined indicator and the NEWPAGE predefined procedure to print headings at the top of the new page. The following commancb for examp1eg would eject the current page and print headings at the top of

C-44 REPORTING AND OUTPUT DataF1ex 2.0 User's Manual

the next page

if

there were less than 6 lines

left

on the current page:

PAGEQIECK 6

Cpagebreak] GOSUB NEWPAGE

The following command would do the same thing unconditiona11y:

FORMFEED GOSUB NEWPAGE

REPETITIVE REPORTS

A report can be put in a loop to execute multiple times for different

selection

criteria.

Put a label at the beginning of the report and

then, at the end of the reportp CLEAR the report data

file

and GOTO

the label at the beginíng of the report. Remember to provide some means for the operator to exit the loop.

MULTIPLE COPIES:

To make multiple copies of a report you must: (I) set your OUTFILE to a disk

file;

and (2) print that

file

multiple times.

OUTFILE "TEMP.$$$"

//

Output to temporary

file

REPORT X BY INDEX.I

//

Do report

----

REPORTENDreport

---

//

The following lines print the disk

file

multiple times DIRECT_OUTPUT "LST:

"

//

Output to printer INTEGER COUNT

SIRING STRVAR 132

//

You must have set up NUMBER 0F_COPIES previously. FOR COUNT FROM

l

TO NUMBER OF_C0PIES

DIRECT_INPUT "TEMP.$$$" [NOT SEQEOF] REPEAT

READLN STRVAR

//

Reads a line from TEMP.$$$ WRITELN STRVAR

//

Writes a line to the printer

[NOT SEQEOF] LOOP

//

End of REPEAT loop

FORMFEED LOOP

li

End of FOR loop

CLOSE_INPUT

//

Close before delete

ERASEFILE "TEMP.$$$"

//

File no longer needed

DataFlex 2.0 User's Manual REPORTING AND OUTPUT C-45

"",_

~

THINGS TO REMEhdER ABOUT THE REPORT MACRO

l.

The REPORT macro may be used only once within a configuration. e

2. The maximum line length which can be output is 255 characters.

3. Fields used as subtotal breakpoints must be indexed. They can be

in the main

file

or in any other RELATEd

file.

4. Subtotal and total registers are updated only by PRINT commands; MOVE, CALCULATE and DISPLAY do not update the registers.

5. Data should be processed only from database elements

or in-memory variables. The contents of formatted windows cannot re?lab1y be used

for calculations or other processing.

6. An invisible AUTOPAGE command is executed at the beginning of each command section. and an invisible RETURN command at the end.

7. The BODY section of the report is executed once for every record

which satisfies the selection

criteria.

REPORTING WITHOUT REPORT

The usual way of configuring reports is by use of the Report macrcn

often starting with the QUERY program to generate the configuration. The Report macro, howevem is by no means the only way of configuring reports--it is merely a pre-programmed convenience suitable to a wide range of purposes. The following configuration outputs a data

file

(called SAMPLE in this example) to the printer in record number sequence, using a format image with a pagename of IMAGE. Note that

it

lacks headings, totals and subtotals commonly found in reports produced by the Report macro.

/IMAGE

l*

OUTFILE °'LST:

"

//Direct output to the printer

OPEN SAMPLE //Open the data

file

to output

CLEAR SAMPLE //Clear the record buffer

CLEARSCREEN //Clear the screen

REPEAT

FIND GT SAMPLE BY RECNUM //Find the next record by number IF0UNDI BEGIN

PRINT SAMPLE.NAME TO IMAGE.I //Must state TO PRINT SAMPLE.CITY TO IMAGE.2' //Window.# since PRINT SAMPLE.STATE TO IMAGE.3 //AUTOPAGE command PRINT SAMPLE.ZIP TO IMAGE.4 //not used

OUTPUT IMAGE END

[NOT SEQEOF] LOOP //Stop at end of

file

ABORT

C-46 REPORTING AND OUTPUT DataF1ex 2.0 User's Manual

——

.

THIS PAGE INTENTIONALLY LEFT BLANK

—————————

ZZZ±ZTZZZZ±ZFF2:

ZZZ::2:::7:::::::7:::7:::::::---

- C-47

========== =========

ZZZZZZTZZZ FILE DEFINITION (FILEDEF) =Z======

========== == —=_—___—

——————— OVERVIEW

The FILEDEF

utility

enables you to create a complete

file

definition

for data base

files

used in a DataFlex application. The

file

definí-

tiom once created, contains information about the

file

namep indexed

fieldm and field information. Each DataFlex

file

must have certain

information about the structure of the data?

file

name, indexes etc.,

established before

it

can be used. Once donm this information

is

avai1ab1ep through the data base managéí"» to any DATAFLEX program.

During execution, the programs can adjust thei r operation to the type and length of the

files

and fields in use. This gives DataF1ex

its

unique APPLICATION INDEPENDENCE.

APPLICATION INDEPENDENCE means that the same data

file

can be used in

multiple applications without the duplication of effort and storage found In most conventional application programs.

EXAMPLE:

We may want to implement accounts receivable, accounts payable and a

mailing

list.

Instead of having three

files

with name and address

informatioñ» we could have one name/address

file

which is referenced by all three applications. Only this one

file

need be defined, stored and updated for names and addresses, thus saving both time and

storage... a real bargain!

Because these data base

files

potent1a1ly are so integrated with the

total application picture, thought and care should be put into the

contents and eventual relationships of the

files.

A well-designed

file

structure will almost automatically mean an effective and

successful app1 ication.

~ ~ ————————————————————————————

C-48 FILE DEFINITION (FILEDEF) DataFlex 2.0 User's Manual "=============———————————————————

STEP ONE

In document DataFlex V2 Jul1984 pdf (Page 152-160)