home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
rep_anom.zip
/
REPORT.COD
< prev
next >
Wrap
Text File
|
1989-02-01
|
50KB
|
2,170 lines
//
// Module Name: REPORT.COD
// Description: Define Application menus and program structure.
//
Report (.frg) Program Template
------------------------------
Version 1.0
Ashton-Tate (c) 1987, 1988
{
include "report.def";
include "builtin.def";
//
// Enum string constants for international translation
//
enum wrong_class = "Can't use REPORT.GEN on non-report objects. ",
report_empty = "Report design was empty. ",
demo_string = "dBASE IV SAMPLE REPORT - FOR EVALUATION PURPOSES ONLY",
increase_page = "Increase the page length for this report.",
demo_version = 0;
//
if frame_class != report then
pause(wrong_class + any_key);
return 0;
endif
//
// temporary storage variables
//
var count,x,a,d,i,ni,j,k,temp,temp2,
//
rptname, // Report name
default_drive, // dBASE default drive
isfirst, // first system memvar? (handles commas)
isnew, // is this a new band?
isopen, // is the band open?
priv_vars, // system memvars list
priv_vars2, // if FLD_EXPRESSION is broken into 2 strings
bandedit, // word wrap off or on
bandgrp, // GROUP id for bands
bandhgt, // band row position plus height plus one
bandlen2, // length of page header (0 if band is closed)
bandlen50, // length of detail band "
bandspacing, // spacing on detail band
bandlen98, // length of page footer "
bandspacing98, // spacing on footer band
bandtype, // type of band ie. page footer, report intro, etc.
band_previous, // previous bandtype
length, // length of field or text
maxgrp, // maximum number of bands
isrepo, // is there report intro/summary bands
maxrow, // maximum row
nextrow, // next row when looking ahead ie. ++<cursor>
current_column, // current text or field plus length
bsrv, // beginning of band suppress repeated value
xsrv, // current suppress repeated value var
xsum, // current "noname" summary field
xxsum, // subset of either an average, std. deviation or variance
samerow, // flag set for items occuring on the same row
bandrow, // band row plus one
first_combine, // text or field is the first in the chain of combined data
combine, // combine fields flag
suppress_line, // if the text "Page no." appears first on the line
previous_row, // previous elements' row
pre_type, // previous element type was field or text
inner_loop, // elements inside the band encountered
optl_heading, // flag to test whether optional heading has been output
is_rintro_open, // is the Report Intro band open
is_rsumm_open, // is the Report Summary band open
number_of_open_group_intros, // none open, Grphead procedure is suppressed
number_of_open_group_summarys, // none open, Grpfoot procedure is suppressed
is_page_header_open, // if Page Header band is open
number_of_reset_on_page, // summary fields reset on page
number_of_fld_suppress, // suppressed fields
intro_band_one_height, // footer widow checking for
intro_band_two_height, // dBASE III PLUS reports
number_of_word_wrap_bands,
number_of_group_footer_fields,
current_group_footer_field,
number_of_begin_new_pages
;
default_drive = STRSET(_defdrive);
rptname = FRAME_PATH + NAME;
if not FILEOK(rptname) then
if FILEDRIVE(NAME) || !default_drive then
rptname=NAME;
else
rptname=default_drive + ":" + NAME;
endif
endif
if not CREATE(rptname+".FRG") then;
PAUSE(fileroot(rptname)+".FRG"+read_only+any_key);
return 0;
endif
}
{bandrow=0;
bsrv=0;
combine=0;
current_column=0;
first_combine=1;
isopen=0;
maxrow=0;
nextrow=0;
optl_heading=0;
previous_row=0;
pre_type=0;
samerow=0;
xsrv=0;
xsum=0;
xxsum=0;
}
* Program............: {rptname}.FRG
* Date...............: {LTRIM(SUBSTR(DATE(),1,8))}
* Versions...........: dBASE IV, Report {FRAME_VER}
*
* Notes:
* ------
* Prior to running this procedure with the DO command
* it is necessary use LOCATE because the CONTINUE
* statement is in the main loop.
*
*-- Parameters
PARAMETERS gl_noeject, gl_plain, gl_summary, gc_heading, gc_extra
** The first three parameters are of type Logical.
** The fourth parameter is a string. The fifth is extra.
PRIVATE _peject\
{if dBASE_III_PLUS == 2 then}
, _plength, _ploffset\
{endif}
, _wrap
*-- Test for no records found
IF EOF() .OR. .NOT. FOUND()
RETURN
ENDIF
*-- turn word wrap mode off
_wrap=.F.
{
isrepo=0;
is_rintro_open=0;
bandlen2=0;
is_page_header_open=0;
bandlen50=0;
number_of_begin_new_pages=0;
number_of_group_footer_fields=0;
number_of_open_group_summarys=0;
number_of_word_wrap_bands=0;
bandlen98=0;
bandspacing=0;
bandspacing98=0;
is_rsumm_open=0;
intro_band_one_height=0;
intro_band_two_height=0;
foreach BAND_ELEMENT k
if BAND_BANDEDIT then ++number_of_word_wrap_bands; endif
if BAND_NEWPAGE then ++number_of_begin_new_pages; endif
case BAND_BANDTYPE of
Report_Intro:
isrepo=1;
if BAND_OPENFLG then is_rintro_open = 1; endif
//
Page_Header:
if BAND_OPENFLG then
is_page_header_open = 1;
bandlen2=BAND_HEIGHT;
endif
//
Group_Intro:
if dBASE_III_PLUS == 2 then
if GROUP == 4 then intro_band_one_height = BAND_HEIGHT; endif
if GROUP == 5 then intro_band_two_height = BAND_HEIGHT; endif
endif
//
Detail:
if BAND_OPENFLG then bandlen50=BAND_HEIGHT; endif
if BAND_SPACING then
bandspacing=BAND_SPACING;
endif
//
Group_Summary:
if BAND_OPENFLG then ++number_of_open_group_summarys; endif
//
Page_Footer:
if BAND_OPENFLG then bandlen98=BAND_HEIGHT; endif
if BAND_SPACING then
bandspacing98=BAND_SPACING;
endif
//
Report_Summary:
if BAND_OPENFLG then is_rsumm_open = 1; endif
endcase
next k;
if demo_version then ++bandlen98; endif
if number_of_open_group_summarys || is_rsumm_open || bandlen98 then
foreach FLD_ELEMENT k
if GROUP > 50 then
d=0;
case FLD_FIELDTYPE of
Tabl_data: d=1;
Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
endcase
if d then
++number_of_group_footer_fields;
endif
endif
next k;
endif
}
IF _plength < {bandlen2+bandlen98+2}
SET DEVICE TO SCREEN
DEFINE WINDOW gw_report FROM 7,17 TO 11,62 DOUBLE
ACTIVATE WINDOW gw_report
@ 0,1 SAY "{increase_page}"
@ 2,1 SAY "{any_key}"
x=INKEY(0)
DEACTIVATE WINDOW gw_report
RELEASE WINDOW gw_report
RETURN
ENDIF
_plineno=0 && set lines to zero
{if dBASE_III_PLUS == 2 then}
*-- dBASE III PLUS report setup
_peject=\
{case PRINT_NEW_PAGE of}
{0:}"AFTER"
{1:}"BEFORE"
{2:}"BOTH"
{3:}"NONE"
{endcase}
_plength={PRINT_PAGE_LENGTH}
_ploffset={nul2zero(PRINT_LEFT_OFFSET)}
{endif}
{if dBASE_III_PLUS == 2 then}
*-- PLAIN option to screen only
IF gl_plain
IF SET("PRINT") = "OFF" .AND. SET("ALTERNATE") = "OFF"
gl_noeject=.T.
ENDIF
ENDIF
{endif}
*-- NOEJECT parameter
IF gl_noeject
IF _peject="BEFORE"
_peject="NONE"
ENDIF
IF _peject="BOTH"
_peject="AFTER"
ENDIF
ENDIF
*-- Set-up environment
ON ESCAPE DO prnabort
IF SET("TALK")="ON"
SET TALK OFF
gc_talk="ON"
ELSE
gc_talk="OFF"
ENDIF
gc_space=SET("SPACE")
SET SPACE OFF
gc_time=TIME() && system time for predefined field
gd_date=DATE() && system date " " " "
gl_fandl=.F. && first and last page flag
gl_prntflg=.T. && Continue printing flag
gl_widow=.T. && flag for checking widow bands
gn_length=LEN(gc_heading) && store length of the HEADING
gn_level=2 && current band being processed
gn_page=_pageno && grab current page number
gn_pspace=_pspacing && get current print spacing
{x=0;
if number_of_group_footer_fields then
current_group_footer_field=1;
x=1;}
*-- Initialize group footer field variables
{ do while x <= number_of_group_footer_fields}
r_foot{x}=.F.
{ ++x;
enddo
endif
}
{x=0;}
{foreach FLD_ELEMENT k}
//
// Reset Summary (on page) and Suppress repeated values
//
{if FLD_FIELDTYPE == Summ_data && FLD_RESET == 1 then
++number_of_reset_on_page
endif}
{if FLD_SUPPRESS then ++number_of_fld_suppress endif}
//
// only if there is a fieldname assigned to the calculated field
//
{if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
{ if !x then}
*-- Initialize calculated variables.
{ endif}
{FLD_FIELDNAME}=\
{case FLD_VALUE_TYPE of}
{68: // Date }CTOD(" / / ")
{70: // Float }FLOAT(0)
{76: // Logical}.F.
{78: // Numeric}0
{otherwise:}""
{endcase}
{ ++x;}
{endif}
{next k;}
*-- Set up procedure for page break
gn_atline=_plength - \
{
// Page footer set to default spacing?
if !bandspacing98 then
// Detail band set to default?
if !bandspacing then
// Page footer height greater than 1?
if bandlen98 > 1 then
}
(_pspacing * {bandlen98} + 1)
{ else}
{ if bandlen98 then}
(_pspacing + 1)
{ else}
1
{ endif
endif
// Detail band is not default
else
bandspacing * bandlen98 +1}
{ endif
// Page footer is not default
else
bandspacing98 * bandlen98 +1}
{endif}
ON PAGE AT LINE gn_atline EJECT PAGE
*-- Print Report
PRINTJOB
{if number_of_begin_new_pages then}
gl_newpage=.T. && ok to begin band on new page
{endif}
{
x=1; // to obtain number of group bands
number_of_open_group_intros=0;
foreach BAND_ELEMENT k
//
if BAND_BANDTYPE == Group_Intro then
if x == 1 then}
*-- Initialize group break vars.
{ endif
if BAND_OPENFLG then ++number_of_open_group_intros; endif}
//
{case BAND_GROUPTYPE of}
{1: // by field}
{// initialize Group by field variable}
r_mvar{GROUP}=\
{ if AT(">",BAND_GFIELD) then // Check for ALIAS}
{SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
{ else}
{BAND_GFIELD}
{ endif}
//
{3: // by record count}
{// initialize Group by record variable}
r_mvar{GROUP}=1
//
{otherwise: // by expression}
{// initialize Group by expression variable}
r_mvar{GROUP}=\
{foreach BAND_EXPRESSION fcursor in k}
{BAND_EXPRESSION}
{next}
//
{endcase}
{ ++x;
endif
if BAND_BANDTYPE == Detail then exit endif
next k;}
{maxgrp=x+2;}
{if x > 1 then}
{endif}
{x=0;}
{foreach FLD_ELEMENT k}
{ if FLD_FIELDTYPE == Summ_data then}
{ if !x then}
*-- Initialize summary variables.
{ endif}
{ ++x;}
//
// standard deviation or variance?
//
{ if !FLD_FIELDNAME then}
{ ++xsum;}
{ priv_vars="r_msum"+STR(xsum);}
{ else}
{ priv_vars=FLD_FIELDNAME;}
{ endif}
{ if FLD_OPERATION > 4 then}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// DECLARE {priv_vars}[5]
// STORE 0 TO {priv_vars}[3]
// STORE 0 TO {priv_vars}[1],{priv_vars}[2],{priv_vars}[4],{priv_vars}[5]
{ else}
{ case FLD_OPERATION of}
{ 0: // Average}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// DECLARE {priv_vars}[3]
// STORE 0 TO {priv_vars}[1]
// STORE 0 TO {priv_vars}[2],{priv_vars}[3]
{ 1: // Count}
{priv_vars}=0
{ otherwise: // Max, Min or Sum}
{priv_vars}=\
{ if FLD_OPERATION == 3 then // Minimum}
{FLD_SUMFIELD}
{ else}
0
{ endif}
{ endcase}
{ endif}
{ endif}
{next k;}
{xsum=0; xxsum=0;}
{if x then}
{endif}
{x=0; // to offset each suppress repeated value variable}
//
{foreach FLD_ELEMENT k}
//
// suppress repeated values?
//
{if FLD_SUPPRESS then}
{ if !x then}
*-- Initialize suppress repeated value variables.
{ endif}
{++x;}
r_msrv{x}=\
{case FLD_VALUE_TYPE of}
{68: // Date }CTOD(" / / ")
{70: // Float }FLOAT(0)
{76: // Logical}.NOT. \
{ if FLD_FIELDNAME then}
{FLD_FIELDNAME}
{ else}
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{78: // Numeric}0
{otherwise:}""
{endcase}
{endif}
{next k;}
{if x then}
{endif}
//
{x=0;}
{foreach FLD_ELEMENT k}
//
// only if there is a fieldname assigned to the calculated field
//
{if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
{ if !x then}
*-- Assign initial values to calculated variables.
{ endif}
{FLD_FIELDNAME}=\
{foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{next}
{ ++x;}
{endif}
{next k;}
{if x then}
{endif}
{x=0;}
{foreach FLD_ELEMENT k}
{ if FLD_FIELDTYPE == Summ_data then}
{ if !FLD_FIELDNAME then}
{ ++xsum;}
{ endif}
{ if FLD_OPERATION == 2 || FLD_OPERATION == 3 then}
{ if !x then}
*-- Initialize min/max summary variables again,
*-- in case it's based on a calculated field.
{ endif}
{ ++x;}
{ if !FLD_FIELDNAME then}
{ priv_vars="r_msum"+STR(xsum);}
{ else}
{ priv_vars=FLD_FIELDNAME;}
{ endif}
{ priv_vars}={FLD_SUMFIELD}
{ endif}
{ endif}
{next k;}
{xsum=0;}
{if x then}
{endif}
{if isrepo && is_rintro_open then}
{ if not FRAME_PAGEHEADINGS then}
DO Rintro
*-- reset page number in case report intro spanned two pages
_pageno=gn_page
{ endif}
{endif}
IF gl_plain
ON PAGE AT LINE gn_atline DO Pgplain
ELSE
ON PAGE AT LINE gn_atline DO Pgfoot
ENDIF
{if is_page_header_open || (is_rintro_open && FRAME_PAGEHEADINGS)
|| number_of_open_group_intros then}
DO Pghead
{endif}
gl_fandl=.T. && first physical page started
{if isrepo && is_rintro_open then}
{ if FRAME_PAGEHEADINGS then}
DO Rintro
{ if number_of_begin_new_pages then}
gl_newpage=.F.
{ endif}
{ endif}
{endif}
{if maxgrp > 3 && number_of_open_group_intros then}
DO Grphead
{endif}
*-- File Loop
DO WHILE FOUND() .AND. .NOT. EOF() .AND. gl_prntflg
//
// If there are group bands
// set up the CASE structure to test
// the group band values
//
{if maxgrp > 3 &&
(number_of_open_group_intros || number_of_open_group_summarys) then}
DO CASE
{ foreach BAND_ELEMENT k}
{ if BAND_BANDTYPE == Group_Intro then}
//
// Group by field
//
{ if BAND_GFIELD then}
CASE .NOT. (\
{ if AT(">",BAND_GFIELD) then // Check for ALIAS}
{SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
{ else}
{BAND_GFIELD}
{ endif}
= r_mvar{GROUP})
{ endif}
//
// Group by expression
//
{ if BAND_EXPRESSION then}
CASE .NOT. (\
{foreach BAND_EXPRESSION fcursor in k}
{BAND_EXPRESSION}
{next}
= r_mvar{GROUP})
{ endif}
//
// Group by record count
//
{ if BAND_GROUP_REC then}
CASE r_mvar{GROUP} > {BAND_GROUP_REC}
{ endif}
gn_level={GROUP}
{ endif}
{ next k;}
OTHERWISE
gn_level=0
ENDCASE
*-- test whether an expression didn't match
IF gn_level <> 0
{ if number_of_open_group_summarys then}
DO Grpfoot WITH 100-gn_level
{ endif}
DO Grpinit
ENDIF
{ if number_of_open_group_intros then}
*-- Repeat group intros
IF gn_level <> 0
DO Grphead
ENDIF
{ endif}
{endif}
{LMARG(4);}
DO Upd_Vars
{if bandlen50 then}
*-- Detail lines
IF .NOT. gl_summary
DO __Detail
ENDIF
{endif}
{if number_of_group_footer_fields || is_rsumm_open || bandlen98 then
x=1;
foreach FLD_ELEMENT k
if GROUP > 50 then
d=0;
case FLD_FIELDTYPE of
Tabl_data: d=1;
Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
endcase
if d then}
r_foot{x}=\
{ case FLD_FIELDTYPE of}
{ Tabl_data:}
{ FLD_FIELDNAME}
{ Calc_data:}
{ FLD_FIELDNAME}
{ Pred_data:}
RECNO()
{ endcase}
{ ++x;}
{ endif
endif
next k;
endif}
CONTINUE
{if number_of_open_group_intros || number_of_open_group_summarys then}
{foreach BAND_ELEMENT k}
{ if BAND_BANDTYPE == Group_Intro then}
//
// increment any group by record count vars.
//
{ if BAND_GROUP_REC then}
r_mvar{GROUP}=r_mvar{GROUP}+1
{ endif}
{ else}
{ if BAND_BANDTYPE > Group_Intro then exit endif}
{ endif}
{next k;}
{endif}
{LMARG(1);}
ENDDO
IF gl_prntflg
//
// If there are group bands
//
{if maxgrp > 3 then}
gn_level=3
{ if number_of_open_group_summarys then}
DO Grpfoot WITH 97
{ endif}
{endif}
//
// Report summary?
//
{if isrepo && is_rsumm_open then}
DO Rsumm
{endif}
{ if bandlen98 then}
{ if !is_rsumm_open then}
gl_fandl=.F. && last page finished
{ endif}
IF _plineno <= gn_atline
EJECT PAGE
ENDIF
{ endif}
ELSE
{if isrepo && is_rsumm_open then}
{ if maxgrp > 3 then}
gn_level=3
{ endif}
DO Rsumm
{endif}
DO Reset
RETURN
ENDIF
ON PAGE
ENDPRINTJOB
DO Reset
RETURN
* EOP: {rptname}.FRG
{x=0;
foreach BAND_ELEMENT k
if BAND_BANDTYPE > Group_Intro then exit endif
if BAND_BANDTYPE == Group_Intro then
if !x then}
*-- Determine height of group bands and detail band for widow checking
FUNCTION Gheight
PARAMETER Group_Band
retval=0 && return value
{ endif}
IF Group_Band <= {GROUP}
retval = retval +\
{ if BAND_HEIGHT > 1 then}
{BAND_HEIGHT}\
{ endif}
{ if !BAND_SPACING && !bandspacing then}
{if BAND_HEIGHT > 1 then} *{endif} gn_pspace
{ else
if !BAND_SPACING && bandspacing > 1 then}
{if BAND_HEIGHT > 1 then} *{endif} {bandspacing}
{ else
if BAND_SPACING > 1 then}
{if BAND_HEIGHT > 1 then} *{endif} {BAND_SPACING}
{ else}
{ if BAND_HEIGHT < 2 then}
{BAND_HEIGHT}\
{ endif}
{ endif
endif
endif}
ENDIF
{ ++x;
endif
next k;
if x then
if bandlen50 then}
*-- add height of detail band
retval = retval + \
{ if !bandspacing then}
{if bandlen50 > 1 then}{bandlen50} * {endif}gn_pspace
{ else}
{ if bandspacing > 1 then}
{bandspacing*bandlen50}
{ else}
{bandlen50}
{ endif
endif
endif}
RETURN retval
* EOP: Gheight
{endif}
*-- Update summary fields and/or calculated fields in the detail band.
PROCEDURE Upd_Vars
{x=0;}
{foreach FLD_ELEMENT k}
//
// Initialize calculated fields for Detail band
//
{ if GROUP == 50 && FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
{FLD_FIELDNAME}=\
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
//
// Summary field?
//
{if FLD_FIELDTYPE == Summ_data then}
{ if !FLD_FIELDNAME then}
{ ++x;}
{ priv_vars="r_msum"+STR(x);}
{ else}
{ priv_vars=FLD_FIELDNAME;}
{ endif}
*-- \
{case FLD_OPERATION of}
{0: // AVG}
Average
r_sum{++xxsum}=r_sum{xxsum}+1{tabto(40)}&& count
// {priv_vars}[1]={priv_vars}[1]+1{tabto(40)}&& count
r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}{tabto(40)}&& sum
// {priv_vars}[2]={priv_vars}[2]+{FLD_SUMFIELD}{tabto(40)}&& sum
{priv_vars}=r_sum{xxsum}/r_sum{xxsum-1}{tabto(40)}&& average
// {priv_vars}[3]={priv_vars}[2]/{priv_vars}[1]{tabto(40)}&& average
{1: // COUNT}
Count
{priv_vars}={priv_vars}+1
{2: // MAX}
Max
IF {FLD_SUMFIELD} > {priv_vars}
{priv_vars}={FLD_SUMFIELD}
ENDIF
{3: // MIN}
Min
IF {FLD_SUMFIELD} < {priv_vars}
{priv_vars}={FLD_SUMFIELD}
ENDIF
{4: // SUM}
Sum
{priv_vars}={priv_vars}+{FLD_SUMFIELD}
{otherwise: // STD or VAR}
{if FLD_OPERATION == 5 then}
Std deviation
{else}
Variance
{endif}
r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}^2\
{tabto(40)}&& sum of squares
// {priv_vars}[1]={priv_vars}[1]+{FLD_SUMFIELD}^2\
// {tabto(40)}&& sum of squares
r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}\
{tabto(40)}&& sum
// {priv_vars}[2]={priv_vars}[2]+{FLD_SUMFIELD}\
// {tabto(40)}&& sum
r_sum{++xxsum}=r_sum{xxsum}+1\
{tabto(40)}&& count
// {priv_vars}[3]={priv_vars}[3]+1\
// {tabto(40)}&& count
r_sum{++xxsum}=r_sum{xxsum-2}/r_sum{xxsum-1}\
{tabto(40)}&& average
// {priv_vars}[4]={priv_vars}[2]/{priv_vars}[3]\
// {tabto(40)}&& average
*-- variance
{priv_vars}=\
(r_sum{xxsum-3}+r_sum{xxsum-1}*(r_sum{xxsum}^2);
-(2*r_sum{xxsum}*r_sum{xxsum-2}))/r_sum{xxsum-1}
// {priv_vars}[5]=\
// ({priv_vars}[1]+{priv_vars}[3]*({priv_vars}[4]^2);
// -(2*{priv_vars}[4]*{priv_vars}[2]))/{priv_vars}[3]
{if FLD_OPERATION == 5 then}
{priv_vars}=SQRT({priv_vars})\
{tabto(40)}&& std deviation
// {priv_vars}[5]=SQRT({priv_vars}[5])\
// {tabto(40)}&& std deviation
{endif}
{endcase}
{endif}
{next k;}
{xxsum=0;}
RETURN
* EOP: Upd_Vars
*-- Set flag to get out of DO WHILE loop when escape is pressed.
PROCEDURE prnabort
gl_prntflg=.F.
RETURN
* EOP: prnabort
{if number_of_open_group_intros || number_of_open_group_summarys then}
*-- Reset group break variables. Reinit summary
*-- fields with reset set to a particular group band.
PROCEDURE Grpinit
{i=0;
x=0;}
{foreach FLD_ELEMENT k}
//
// Summary field and reset on group?
//
{ if FLD_FIELDTYPE == Summ_data && FLD_RESET >= Each_Group then}
{ if i && FLD_RESET > Each_Group && i != FLD_RESET then}
{ i=0;
lmarg(1);}
ENDIF
{ endif}
{ if FLD_RESET > Each_Group && i != FLD_RESET then}
IF gn_level <= {FLD_RESET}
{ i=FLD_RESET;
lmarg(4);}
{ endif}
{ if !FLD_FIELDNAME then}
{ ++x;}
{ priv_vars="r_msum"+STR(x);}
{ else}
{ priv_vars=FLD_FIELDNAME;}
{ endif}
//
// standard deviation or variance?
//
{ if FLD_OPERATION > 4 then}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// STORE 0 TO {priv_vars}[3]
// STORE 0 TO {priv_vars}[1],{priv_vars}[2],\
// {priv_vars}[4],{priv_vars}[5]
{ else}
{ case FLD_OPERATION of}
{ 0: // Average}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// STORE 0 TO {priv_vars}[1]
// STORE 0 TO {priv_vars}[2],{priv_vars}[3]
{ 1: // Count}
{priv_vars}=0
{ otherwise: // Min, Max or Sum}
{priv_vars}=\
{ if FLD_OPERATION == 3 then // Minimum}
{FLD_SUMFIELD}
{ else}
0
{ endif}
{ endcase}
{ endif}
{ endif}
{next k;}
{xxsum=0;}
{if i then
i=0;
lmarg(1);}
ENDIF
{endif}
{foreach BAND_ELEMENT k}
{ if BAND_BANDTYPE == Group_Intro then}
//
// Reset Group break vars on group intro bands
//
IF gn_level <= {GROUP}
//
{ lmarg(4);}
{ if BAND_GFIELD then}
r_mvar{GROUP}=\
{ if AT(">",BAND_GFIELD) then // Check for ALIAS}
{SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
{ else}
{BAND_GFIELD}
{ endif}
{ endif}
{ if BAND_GROUP_REC then}
r_mvar{GROUP}=1
{ endif}
{ if BAND_EXPRESSION then}
r_mvar{GROUP}=\
{foreach BAND_EXPRESSION fcursor in k}
{BAND_EXPRESSION}
{next}
{ endif}
{ lmarg(1);}
ENDIF
{ else}
{ if BAND_BANDTYPE > Group_Intro then exit endif}
{ endif}
{next k;}
RETURN
* EOP: Grpinit
{endif}
{if number_of_reset_on_page || number_of_fld_suppress then}
*-- Reset summary fields (on page) and suppress repeated values.
PROCEDURE Pageinit
{i=0;}
{x=0;}
{foreach FLD_ELEMENT k}
{ if FLD_SUPPRESS then}
{ ++x;}
r_msrv{x}=\
{ case FLD_VALUE_TYPE of}
{ 68: // Date}CTOD(" / / ")
{ 70: // Float}FLOAT(0)
{ 76: // Logical}.NOT. \
{ if FLD_FIELDNAME then}
{FLD_FIELDNAME}
{ else}
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ 78: // Numeric}0
{ otherwise:}""
{ endcase}
{ endif}
{ if FLD_FIELDTYPE == Summ_data && FLD_RESET == Each_Page then}
{ if !FLD_FIELDNAME then}
{ ++i;}
{ priv_vars="r_msum"+STR(i);}
{ else}
{ priv_vars=FLD_FIELDNAME;}
{ endif}
{ if FLD_OPERATION > 4 then}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// STORE 0 TO {priv_vars}[3]
// STORE 0 TO {priv_vars}[1],{priv_vars}[2],\
// {priv_vars}[4],{priv_vars}[5]
{ else}
{ case FLD_OPERATION of}
{ 0: // Average}
STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
// STORE 0 TO {priv_vars}[1]
// STORE 0 TO {priv_vars}[2],{priv_vars}[3]
{ 1: // Count}
{priv_vars}=0
{ otherwise: // Min,Max or Sum}
{priv_vars}=\
{ if FLD_OPERATION == 3 then // Minimum}
{FLD_SUMFIELD}
{ else}
0
{ endif}
{ endcase}
{ endif}
{ endif}
{next k;}
{xxsum=0;}
RETURN
* EOP: Pageinit
{endif}
{if maxgrp > 3 &&
(number_of_open_group_intros || number_of_open_group_summarys) then}
{ if number_of_open_group_intros then}
*-- Process Group Intro bands during group breaks
PROCEDURE Grphead
IF EOF()
RETURN
ENDIF
PRIVATE _pspacing
{if bandspacing then}
_pspacing={bandspacing}
{else}
_pspacing=gn_pspace
{endif}
gl_widow=.T. && enable widow checking
{ endif}
{ if dBASE_III_PLUS == 2 && !number_of_open_group_summarys then}
IF gn_level > 3
?
ENDIF
{ endif}
{foreach BAND_ELEMENT k}
{ case BAND_BANDTYPE of}
{ Group_Intro:}
{ if BAND_OPENFLG then}
IF gn_level <= {GROUP}
DO Head{GROUP}
ENDIF
{ endif}
{ Detail:}
{ if number_of_open_group_intros then}
gn_level=0
RETURN
* EOP: Grphead.PRG
{ endif}
{ if number_of_open_group_summarys then}
*-- Process Group Summary bands during group breaks
PROCEDURE Grpfoot
PARAMETER ln_level
{ endif}
{ Group_Summary:}
{ if BAND_OPENFLG then}
IF ln_level >= {GROUP}
DO Foot{GROUP}
ENDIF
{ endif}
{ Page_Footer:}
{ if number_of_open_group_summarys then}
RETURN
* EOP: Grpfoot.PRG
{ endif}
{ endcase}
{next k;}
{endif}
{bandtype=99;}
//
{foreach ELEMENT ecursor}
{ inner_loop=0;}
{ pre_type=0;}
//
// List type is a BAND?
//
{if ELEMENT_TYPE == @Band_Element then}
{ band_previous=bandtype;
bandtype=BAND_BANDTYPE;}
//
// reset samerow to zero if set and output a carriage return
//
{ if samerow then}
{ samerow=0;}
//
{ endif}
{ combine=0;}
{ first_combine=1;}
//
// Output carriage returns for dBASE report to handle blank lines
//
{ nextline2:}
{ if maxrow < bandhgt then}
{ if isopen then}
?
{ endif}
{ ++maxrow;}
{ goto nextline2;}
{ endif}
//
// beyond the first band?
//
{ if band_previous != 99 then}
//
{ if number_of_begin_new_pages then
if band_previous == Group_Intro
|| band_previous == Detail
|| band_previous == Group_Summary then}
gl_newpage=.F.
{ endif}
{ endif}
{ if band_previous == Page_Header || band_previous == Page_Footer
|| isopen then}
{ case band_previous of}
{ Page_Header:}
//
{ if suppress_line then
suppress_line=0;}
//
{ lmarg(1);}
ENDIF
{ endif}
//
{ if isopen || (is_rintro_open && FRAME_PAGEHEADINGS)
|| number_of_open_group_intros then}
//
// Insert heading code for no page number
//
{ if !optl_heading then}
*-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
IF .NOT. gl_plain .AND. gn_length > 0
?? gc_heading FUNCTION "I;V"+LTRIM(STR(_rmargin-_lmargin))
?
ENDIF
{ optl_heading=1;}
{ endif}
//
RETURN
* EOP: Pghead
{ endif}
{ Report_Intro:}
RETURN
* EOP: Rintro
{ Group_Intro:}
RETURN
{ Detail:}
RETURN
* EOP: __Detail
{ Group_Summary:}
{if dBASE_III_PLUS == 2 then}
IF ln_level < 9{if GROUP == 96 then}6{else}7{endif}
?
ENDIF
{endif}
RETURN
{ Report_Summary:}
gl_fandl=.F. && last page finished
?
RETURN
* EOP: Rsumm
{ Page_Footer:}
{ finish_page_footer();}
{ endcase}
{ endif}
{ endif}
//
// capture band attributes
// -----------------------
// bandrow and maxrow for row position
// bandedit for word wrap band
// isopen for band open or closed
//
{ if Row_Positn then
bandhgt=Row_Positn+BAND_HEIGHT+1;
bandrow=Row_Positn+1;
maxrow=Row_Positn+1;
else
bandhgt=BAND_HEIGHT+1;
bandrow=1;
maxrow=1;
endif
}
{ bandedit=BAND_BANDEDIT;}
{ bandgrp=GROUP;}
{ bsrv=xsrv;}
{ isnew=1;}
{ isopen=BAND_OPENFLG;}
//
{ if BAND_BANDTYPE == Page_header || BAND_BANDTYPE == Page_Footer
|| BAND_OPENFLG then}
{ if BAND_BANDTYPE then}
PROCEDURE \
{ else}
{ if BAND_OPENFLG || (is_rintro_open && FRAME_PAGEHEADINGS)
|| number_of_open_group_intros then}
PROCEDURE \
{ endif}
{ endif}
{ case bandtype of}
{ Page_Header:}
{ if BAND_OPENFLG || (is_rintro_open && FRAME_PAGEHEADINGS)
|| number_of_open_group_intros then}
Pghead
{ endif}
{ Report_Intro:}
Rintro
{ Group_Intro:}
Head{GROUP}
{ if not BAND_INTROEACH then}
IF gn_level=1
RETURN
ENDIF
{ endif}
{ if dBASE_III_PLUS == 2 && GROUP == 4 &&
intro_band_one_height && intro_band_two_height then
++bandhgt;
endif}
{ Detail:}
__Detail
{ Group_Summary:}
Foot{GROUP}
{ if dBASE_III_PLUS == 2 then}
ln_lines=IIF(ln_level < 97, \
{ case GROUP of
96:}
{intro_band_one_height+intro_band_two_height+2}, \
{intro_band_one_height+intro_band_two_height+1})
{ 95:}
{intro_band_two_height+2}, \
{intro_band_two_height+1})
{ endcase}
IF _plineno+ln_lines > gn_atline
_plineno=gn_atline
?
ENDIF
{ endif}
{ Report_Summary:}
Rsumm
{ --bandhgt;}
{ Page_Footer:}
Pgfoot
PRIVATE _box{if isopen}, _pspacing{endif}
gl_widow=.F. && disable widow checking
{ if isopen then}
_pspacing=1
?
{ endif}
{ --bandhgt;}
{ if BAND_OPENFLG && BAND_HEIGHT then}
IF .NOT. gl_plain
{ endif}
{ endcase}
{ endif}
//
// is the band open?
// make system memvars PRIVATE
// only if the values change
//
{ if isopen then}
//
// BAND_NEWPAGE - Begin band on new page: No, Yes|
//
{ if BAND_NEWPAGE then}
IF .NOT. gl_newpage
gl_newpage=.T.
EJECT PAGE
ENDIF
{ endif}
//
// BAND_TEXTPITCH - Text pitch for band: Pica, Elite, Condensed, Default|
//
{ if BAND_TEXTPITCH != 3 then}
IF SET("PRINT") = "ON" .AND. _ppitch <> \
{ case BAND_TEXTPITCH of}
{ 0:}
"PICA"
{ 1:}
"ELITE"
{ 2:}
"CONDENSED"
{ 3:}
"DEFAULT"
{ endcase}
PRIVATE _ppitch
_ppitch = \
{ case BAND_TEXTPITCH of}
{ 0:}
"PICA"
{ 1:}
"ELITE"
{ 2:}
"CONDENSED"
{ 3:}
"DEFAULT"
{ endcase}
ENDIF
{ endif}
//
// BAND_QUALITY - Quality pitch for band: Yes, No|
//
{ if BAND_QUALITY < 2 then}
IF SET("PRINT") = "ON" .AND. {if !BAND_QUALITY then}.NOT. {endif}_pquality
PRIVATE _pquality
_pquality = \
{ if BAND_QUALITY then}
.F.
{ else}
.T.
{ endif}
ENDIF
{ endif}
//
// BAND_SPACING - Default, single, double or triple
//
{ if BAND_SPACING then}
IF _pspacing <> {BAND_SPACING}
PRIVATE _pspacing
_pspacing={BAND_SPACING}
ENDIF
{ endif}
//
// BAND_BANDEDIT - Wordwrap band: Yes, No|
//
{ if number_of_word_wrap_bands then}
{ if BAND_BANDEDIT then}
PRIVATE _indent, _lmargin, _rmargin, _tabs
{ endif}
IF { if BAND_BANDEDIT then}.NOT. {endif}_wrap
PRIVATE _wrap
_wrap = \
{ if BAND_BANDEDIT then}
.T.
{ else}
.F.
{ endif}
ENDIF
{ endif}
//
{ i=GROUP;}
//
// Initialize calculated fields
// in case they are used in the group break procedure
//
{ if BAND_BANDTYPE != Detail then}
{ foreach FLD_ELEMENT k}
{ if GROUP == i && FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
{FLD_FIELDNAME}=\
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ next k;}
{ endif}
//
// Check for possible widow band
//
{ if BAND_BANDTYPE == Group_Intro then}
//
{ x=0;
i=GROUP;
foreach BAND_ELEMENT k
//
// GROUP >= i means current Group intro
//
if k.BAND_OPENFLG && k.GROUP >= i then
if k.BAND_BANDTYPE <= Detail then
x=x+k.BAND_HEIGHT;
else
exit
endif
endif
next k;
}
//
{ ni="";
if x then
if !BAND_SPACING && !bandspacing then
ni=" * gn_pspace";
else
if !BAND_SPACING && bandspacing > 1 then
ni=" * "+STR(bandspacing);
else
if BAND_SPACING > 1 then
ni=" * "+STR(BAND_SPACING);
endif
endif
endif
if BAND_HEIGHT > 1 then
a=STR(BAND_HEIGHT)+ni+" ";
else
if ni then
a=SUBSTR(ni,4)+" ";
else
a="";
endif
endif
if a then}
IF {a} < _plength
{ lmarg(4);}
IF (gl_widow .AND. _plineno+Gheight({GROUP}) > gn_atline + 1)\
{ if BAND_HEIGHT then}
;
.OR. (gl_widow .AND. _plineno+\
{ if BAND_HEIGHT > 1 then}
{BAND_HEIGHT}{ni}\
{ else}
{ if !BAND_SPACING then}
{ if ni then}
{SUBSTR(ni,4)}\
{ else}
1\
{ endif}
{ else}
{BAND_SPACING}\
{ endif
endif}
> gn_atline)
{ else}
{ endif
endif}
EJECT PAGE
ENDIF
{ lmarg(1);}
ENDIF
{ endif}
{ endif}
//
{ ni="";
if BAND_BANDTYPE == Detail then
if BAND_HEIGHT then
if !bandspacing then
if BAND_HEIGHT > 1 then
ni=STR(BAND_HEIGHT)+" * gn_pspace";
else
ni="gn_pspace";
endif
else
if bandspacing > 1 then
ni=STR(BAND_HEIGHT * BAND_SPACING);
else
if BAND_HEIGHT > 1 then
ni=STR(BAND_HEIGHT);
endif
endif
endif
if ni then}
IF {ni} < _plength
IF gl_widow .AND. _plineno+{ni} > gn_atline + 1
EJECT PAGE
ENDIF
ENDIF
{ endif
endif
endif}
{ if Row_Positn then previous_row=Row_Positn endif;}
{ endif}
{ loop}
{else}
{ ++count;}
{endif}
{do while ELEMENT_TYPE != @Band_Element && !eoc(ecursor)}
{ inner_loop=1;}
//
{ if FLD_SUPPRESS then}
{ ++xsrv;}
{ endif}
//
{ if FLD_HIDDEN || not isopen goto noprint endif}
//
// List type is TEXT or FIELD?
//
{ if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
{ if pre_type && maxrow == Row_Positn then}
{ samerow=1;}
{ else}
{ samerow=0;}
{ combine=0;}
{ first_combine=1;}
{ endif}
{ endif}
//
// Output carriage returns for dBASE report
//
{ if !bandedit then}
{ nextline1:}
{ if maxrow < Row_Positn then}
?
{ ++maxrow;}
{ goto nextline1;}
{ endif}
{ else}
{ maxrow=Row_Positn;}
{ endif}
//
// Insert heading code for no page number
//
{ if !optl_heading && bandtype == Page_Header &&
Row_Positn > bandrow+1 && !suppress_line then}
*-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
IF .NOT. gl_plain .AND. gn_length > 0
?? gc_heading FUNCTION "I;V"+LTRIM(STR(_rmargin-_lmargin))
?
ENDIF
{ optl_heading=1;}
{ endif}
//
{ pre_type=0;}
//
{ case ELEMENT_TYPE of}
{ @Text_Element:}
//
{ x=Col_Positn;}
{ i=LEN(Text_Item);}
{ ni=0;}
{ pre_type=1;}
{ if i == 237 then}
{ foreach Text_Item fcursor in ecursor}
{ if ni then}
{ i=i+LEN(Text_Item);}
{ temp=Text_Item;}
{ endif}
{ ++ni;}
{ next}
{ endif}
{ current_column=x+i;}
{ ++ecursor;}
{ nextrow=Row_Positn;}
{ if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
{ if current_column == Col_Positn && maxrow == Row_Positn then}
{ combine=1;}
{ else}
{ combine=0;}
{ endif}
{ if (bandtype == Page_Header || bandtype == Page_Footer) &&
ELEMENT_TYPE == @Fld_Element && nextrow == maxrow then}
{ if FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE == 3 then}
{ --ecursor;}
{ if SUBSTR(UPPER(Text_Item),1,4) == "PAGE" then
suppress_line=1;
endif}
{ ++ecursor;}
{ if suppress_line then}
{ ++ecursor;}
{ if !eoc(ecursor) && Row_Positn == nextrow then}
{ suppress_line=2;}
{ endif}
{ --ecursor;}
{ endif}
{ endif}
{ endif}
{ endif}
{ --ecursor;}
//
{ if suppress_line == 1 &&
(bandtype == Page_Header || bandtype == Page_Footer) then
plainopt(ecursor);
endif}
{ if isnew then}
{ isnew=0;}
?? \
{ else}
{ if samerow then}
?? \
{ else}
?? \
{ endif}
{ endif}
{ if suppress_line == 2 then}
IIF(gl_plain,'' , \
{ endif}
{ if i > 70 then}
;
{ seperate(Text_Item);}
{ if ni then}
+ "{temp}";
{ endif}
{ else}
"{Text_Item}" \
{ endif}
{ if suppress_line == 2 then}
) \
{ suppress_line=0;}
{ endif}
{ @Box_Element:}
DEFINE BOX FROM {nul2zero(BOX_LEFT)} TO {nul2zero(BOX_LEFT)+BOX_WIDTH-1} \
HEIGHT {BOX_HEIGHT} \
{ case BOX_TYPE of}
{ 0: // Single}
SINGLE
{ 1: // Double}
DOUBLE
{ 2: // Defined}
CHR({BOX_SPECIAL_CHAR})
{ endcase}
{ nextrow=Row_Positn;}
{ @Page_Element:}
EJECT PAGE
{ @Para_Element:}
?
{ @Ruler_Element:}
_indent={nul2zero(RULER_INDENT)}
_lmargin={nul2zero(RULER_LEFTM)}
_pcolno={nul2zero(RULER_LEFTM)}
_rmargin={RULER_RIGHTM}
_tabs=\
{ if LEN(RULER_TABS) > 70 then}
;
{ seperate(RULER_TABS);}
{ else}
"{RULER_TABS}"
{ endif}
{ @Fld_Element:}
//
{ x=Col_Positn;}
{ i=FLD_REPWIDTH;}
{ ni=0;}
{ pre_type=1;}
{ if i > 237 then}
{ foreach FLD_TEMPLATE fcursor in ecursor}
{ if ni then}
{ temp2=FLD_TEMPLATE;}
{ endif}
{ ++ni;}
{ next}
{ endif}
{ current_column=x+i;}
//
{ ++ecursor;}
{ nextrow=Row_Positn;}
{ if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
{ if current_column == Col_Positn && maxrow == Row_Positn then}
{ combine=1;}
{ else}
{ combine=0;}
{ endif}
{ endif}
{ --ecursor;}
//
{ k=0;}
{ x=0;}
{ priv_vars2="";}
{ if dBASE_III_PLUS == 2 && CHR(FLD_VALUE_TYPE) == "C" &&
(FLD_FIELDTYPE == Tabl_data || FLD_FIELDTYPE == Calc_data) then}
{ priv_vars="TRIM(";}
{ x=1;}
{ else}
{ priv_vars="";}
{ endif}
{ d=0;
if GROUP > 50 then
case FLD_FIELDTYPE of
Tabl_data: d=1;
Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
endcase
endif
if d then}
{ priv_vars="r_foot"+STR(current_group_footer_field);}
{ ++current_group_footer_field;}
{ else}
{ case FLD_FIELDTYPE of}
{ Tabl_data:}
// With ALIAS
//{ priv_vars=priv_vars+FLD_FILENAME+"->"+FLD_FIELDNAME;}
// Without ALIAS
{ priv_vars=priv_vars+FLD_FIELDNAME;}
{ Calc_data:}
{ if FLD_FIELDNAME then}
{ priv_vars=priv_vars+FLD_FIELDNAME;}
{ else}
{ foreach FLD_EXPRESSION fcursor in ecursor}
{ if k then}
{ priv_vars2=FLD_EXPRESSION;}
{ endif}
{ ++k;}
{ next}
{ if (UPPER(SUBSTR(LTRIM(FLD_EXPRESSION),1,5))) != "TRIM(" then}
{ priv_vars=priv_vars+FLD_EXPRESSION;}
{ else}
{ priv_vars=FLD_EXPRESSION;}
{ x=0;}
{ endif}
{ endif}
{ Pred_data:}
{ case FLD_PREDEFINE of}
{ 0: // Date}
{ priv_vars="gd_date";}
{ 1: // Time}
{ priv_vars="gc_time";}
{ 2: // Recno}
{ priv_vars="RECNO()";}
{ 3: // Pageno}
{ priv_vars="_pageno";}
{ endcase}
{ Summ_data:}
{ if !FLD_FIELDNAME then}
{ ++xsum;}
{ priv_vars="r_msum"+STR(xsum);}
//{ case FLD_OPERATION of}
//{ 0: // Average}
//{ priv_vars=priv_vars+"[3]";}
//{ 5: // standard deviation}
//{ priv_vars=priv_vars+"[5]";}
//{ 6: // variance}
//{ priv_vars=priv_vars+"[5]";}
//{ endcase}
{ else}
{ priv_vars=FLD_FIELDNAME;}
//{ case FLD_OPERATION of}
//{ 0: // Average}
//{ priv_vars=FLD_FIELDNAME+"[3]";}
//{ 5: // standard deviation}
//{ priv_vars=FLD_FIELDNAME+"[5]";}
//{ 6: // variance}
//{ priv_vars=FLD_FIELDNAME+"[5]";}
//{ otherwise: // count, min, max or sum}
//{ priv_vars=FLD_FIELDNAME;}
//{ endcase}
{ endif}
{ endcase}
{ endif}
{ if x then}
{ priv_vars2=priv_vars2+")";}
{ endif}
{ if !suppress_line &&
(bandtype == Page_Header || bandtype == Page_Footer) then}
{ plainopt(ecursor);}
{ endif}
//
// For output of suppress repeated value memo fields
//
{ if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
lf_temp=\
{ goto memo_patch1}
{ endif}
{ memo_patch2:}
{ if isnew then}
{ isnew=0;}
?? \
{ else}
{ if samerow then}
, \
{ else}
?? \
{ endif}
{ endif}
{ if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
&lf_temp. \
{ goto memo_patch3}
{ endif}
{ memo_patch1:}
//
// Suppress repeated values?
//
{ if FLD_SUPPRESS then}
IIF(\
//
// Date field?
//
{ if CHR(FLD_VALUE_TYPE) == "D" then}
DTOS(r_msrv{xsrv}) \
{ else}
r_msrv{xsrv} \
{ endif}
<> \
//
// Date field?
//
{ if CHR(FLD_VALUE_TYPE) == "D" then}
DTOS({priv_vars}{priv_vars2})\
{ else}
//
// Memo field?
//
{ if CHR(FLD_VALUE_TYPE) == "M" then}
LEFT({priv_vars},254)\
{ else}
{priv_vars}{priv_vars2}
{ endif}
{ endif}
//
// Memo field?
//
{ if CHR(FLD_VALUE_TYPE) == "M" then}
,[{priv_vars}],[""])
{ else}
,{priv_vars}{priv_vars2},"") \
{ endif}
{ else}
{ priv_vars}{priv_vars2} \
{ endif}
{ if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
{ goto memo_patch2}
{ endif}
{ memo_patch3:}
{ j=0;}
{ if FLD_PICFUN then}
{ temp=FLD_PICFUN;}
{ j=AT("V",temp) | AT("H",temp);}
{ if not j then}
FUNCTION "{FLD_PICFUN}" \
{ else}
{ if not AT("H",temp) then
if j < LEN(FLD_PICFUN) then
temp=SUBSTR(temp,1,j)+STR(i)+SUBSTR(temp,j+1);
else
temp=temp+STR(i);
endif
endif}
FUNCTION "{temp}" \
{ endif}
{ endif}
{ temp=FLD_TEMPLATE+temp2;}
{ if FLD_VALUE_TYPE == 67 then
if FLD_LENGTH == FLD_REPWIDTH && temp == REPLICATE("X",FLD_LENGTH) then
j=FLD_LENGTH;
endif
endif}
{ if not j then}
//
// test for invalid picture templates
//
{ if temp && (FLD_FIELDTYPE != Pred_data || FLD_PREDEFINE != 1) &&
CHR(FLD_VALUE_TYPE) != "D" then}
{ if i > 70 then}
PICTURE ;
{ seperate(temp);}
{ else}
PICTURE "{FLD_TEMPLATE}" \
{ endif}
{ endif}
{ endif}
{ endcase}
//
// Style of output ie. BOLD, UNDERLINE and ITALICS.
//
{ if FLD_STYLE then}
STYLE "\
{ if Bold & FLD_STYLE then}
B\
{ endif}
{ if Italic & FLD_STYLE then}
I\
{ endif}
{ if Underline & FLD_STYLE then}
U\
{ endif}
{ if Superscript & FLD_STYLE then}
R\
{ endif}
{ if Subscript & FLD_STYLE then}
L\
{ endif}
{ if User_Font & FLD_STYLE then}
{ if 1 & FLD_STYLE then}1{endif}\
{ if 2 & FLD_STYLE then}2{endif}\
{ if 4 & FLD_STYLE then}3{endif}\
{ if 8 & FLD_STYLE then}4{endif}\
{ if 16 & FLD_STYLE then}5{endif}\
{ endif}
" \
{ endif}
//
// List type is TEXT or FIELD?
//
{ if (ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element) then}
//
// not a word wrap band?
//
{ if !bandedit && first_combine then}
AT {Col_Positn}\
{ if maxrow == nextrow then}
,
{ else}
{ endif}
{ isnew=1;}
{ else}
{ if maxrow == nextrow then}
,
{ isnew=1;}
{ else}
{ endif}
{ endif}
//
// ***********************
//
{ if FLD_SUPPRESS && bsrv != xsrv then}
//
IF .NOT. (r_msrv{xsrv} = \
//
{ if !FLD_FIELDNAME then}
{ if FLD_FIELDTYPE == Calc_data then}
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ if FLD_FIELDTYPE == Summ_data then}
r_msum{xsum}\
{ endif}
{ else}
{ if CHR(FLD_VALUE_TYPE) == "M" then}
LEFT({FLD_FIELDNAME},254)\
{ else}
{FLD_FIELDNAME}
{ endif}
{ endif}
)
{ if !FLD_FIELDNAME then}
r_msrv{xsrv}=\
{ if FLD_FIELDTYPE == Calc_data then}
{ foreach FLD_EXPRESSION fcursor in k}
{FLD_EXPRESSION}
{ next}
{ endif}
{ if FLD_FIELDTYPE == Summ_data then}
r_msum{xsum}
{ endif}
{ else}
r_msrv{xsrv}={FLD_FIELDNAME}
{ endif}
ENDIF
{ endif}
//
{ samerow=1;}
{ if first_combine && combine then}
{ first_combine=0;}
{ endif}
//
{ if !combine && !first_combine then}
{ first_combine=1;}
{ endif}
{ endif}
{ if bandtype == Page_Header || bandtype == Page_Footer then}
{ x=0;}
{ if previous_row < maxrow && nextrow > maxrow &&
FLD_FIELDTYPE == Pred_data &&
(!FLD_PREDEFINE || FLD_PREDEFINE == 3) then
x=1;
endif}
{ if x || (suppress_line && nextrow > maxrow) then}
{ if suppress_line && nextrow > maxrow then suppress_line=0; endif}
//
{ if optl_heading && nextrow > maxrow then}
?
{ ++maxrow;}
{ endif}
{ lmarg(1);}
ENDIF
//
// Insert heading code if pageno exists
//
{ if !optl_heading && bandtype == Page_Header && bandrow+1 == Row_Positn
&& FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE == 3 then}
*-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
IF .NOT. gl_plain .AND. gn_length > 0
?? " "
?? gc_heading FUNCTION "I;V"+;
LTRIM(STR(_rmargin-_lmargin-(_pcolno*2+2)))
ENDIF
{ if nextrow > maxrow then}
IF .NOT. gl_plain
?
ENDIF
{ ++maxrow;}
{ isnew=1;}
{ endif}
{ optl_heading=1;}
{ endif}
//
{ endif}
{ endif}
{ noprint:}
{ x=0;}
{ previous_row=Row_Positn;}
{ ++ecursor;}
{enddo}
{if inner_loop then --ecursor; endif}
{next ecursor;}
//
// Output carriage returns for dBASE report to handle blank lines
//
{nextline3:}
{if maxrow < bandhgt then}
{ if isopen then}
?
{ endif}
{ ++maxrow;}
{ goto nextline3;}
{endif}
{if bandtype == Report_Summary && is_rsumm_open then}
gl_fandl=.F.
?
RETURN
* EOP: Rsumm
{endif}
{if bandtype == Page_Footer then}
{ finish_page_footer();}
{endif}
*-- Process page break when PLAIN option is used.
PROCEDURE Pgplain
PRIVATE _box
EJECT PAGE
{if number_of_reset_on_page || number_of_fld_suppress then}
IF gl_fandl
DO Pageinit
ENDIF
{endif}
{if maxgrp > 3 && number_of_open_group_intros then}
IF gn_level = 0 .AND. gl_fandl
gn_level=1
DO Grphead
ENDIF
{endif}
RETURN
* EOP: Pgplain
*-- Reset dBASE environment prior to calling report
PROCEDURE Reset
SET SPACE &gc_space.
SET TALK &gc_talk.
ON ESCAPE
ON PAGE
RETURN
* EOP: Reset
{if !count then pause(report_empty + any_key); endif}
{Nogen:}
{return 0;}
//--------------------------------
// End of main template procedure
// User defined functions follow
//--------------------------------
{define nul2zero(number);
if !number then
number=0;
endif
return number;
enddef
}
//
{
define seperate(string);
var x,y,length;
x=1;
length=LEN(string);
moreleft:
if x <= length then
if x != 1 then}
+ \
{ endif
if x+70 <= length then y=70; else y=length-x+1; endif}
"{SUBSTR(string,x,y)}";
{ x=x+70;
goto moreleft;
endif
return;
enddef
}
{define plainopt(cursor);
var temp; temp=0;
if previous_row < maxrow && nextrow > maxrow &&
cursor.FLD_FIELDTYPE == Pred_data &&
(!cursor.FLD_PREDEFINE || cursor.FLD_PREDEFINE == 3) then
temp=1;
endif}
{ if temp || suppress_line then}
IF .NOT. gl_plain
{ LMARG(4);
else
if cursor.FLD_FIELDTYPE == Pred_data &&
(!cursor.FLD_PREDEFINE || cursor.FLD_PREDEFINE == 3) then
if !cursor.FLD_PREDEFINE then
priv_vars="IIF(gl_plain,'',gd_date)";
else
priv_vars="IIF(gl_plain,'',_pageno)";
endif
endif
endif
return;
enddef}
{define finish_page_footer();}
{ if suppress_line then
suppress_line=0;}
//
{ LMARG(1);}
ENDIF
{ endif}
{ if isopen && bandhgt+1 then}
ENDIF
{ endif}
{ if demo_version then}
? "{demo_string}" FUNCTION "IV"+LTRIM(STR(_rmargin-_lmargin))
{ endif}
EJECT PAGE
{ if number_of_begin_new_pages then}
gl_newpage=.T.
{ endif}
*-- is the page number greater than the ending page
IF _pageno > _pepage
GOTO BOTTOM
SKIP
gn_level=0
ENDIF
{ if number_of_reset_on_page || number_of_fld_suppress then}
IF gl_fandl
DO Pageinit
ENDIF
{ endif}
{ if is_page_header_open || (is_rintro_open && FRAME_PAGEHEADINGS)
|| number_of_open_group_intros then}
IF .NOT. gl_plain .AND. gl_fandl
{if bandspacing then}
_pspacing={bandspacing}
{else}
_pspacing=gn_pspace
{endif}
DO Pghead
ENDIF
{ endif}
{ if maxgrp > 3 && number_of_open_group_intros then}
IF gn_level = 0 .AND. gl_fandl
gn_level=1
DO Grphead
ENDIF
{ endif}
gl_widow=.T. && enable widow checking
RETURN
* EOP: Pgfoot
{return;
enddef}
// EOP: REPORT.COD