home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / db4bugs.zip / REPORT.COD < prev    next >
Text File  |  1989-04-13  |  50KB  |  2,170 lines

  1. //
  2. // Module Name: REPORT.COD
  3. // Description: Define report program structure.
  4. //
  5.  
  6. Report (.frg) Program Template
  7. ------------------------------
  8. Version 1.1
  9. Ashton-Tate (c) 1987, 1988
  10.  
  11. {
  12.  include "report.def";
  13.  include "builtin.def";
  14. //
  15. // Enum string constants for international translation
  16. //
  17.  enum wrong_class = "Can't use REPORT.GEN on non-report objects.  ",
  18.      report_empty = "Report design was empty.  ",
  19.      demo_string  = "dBASE IV SAMPLE REPORT - FOR EVALUATION PURPOSES ONLY",
  20.     increase_page = "Increase the page length for this report.",
  21.      demo_version = 0;
  22. //
  23.  if frame_class != report then
  24.    pause(wrong_class + any_key);
  25.    return 0;
  26.  endif
  27. //
  28. // temporary storage variables
  29. //
  30.  var count,x,a,d,i,ni,j,k,temp,temp2,
  31. //
  32.      rptname,   // Report name
  33.  default_drive, // dBASE default drive
  34.      isfirst,   // first system memvar? (handles commas)
  35.      isnew,     // is this a new band?
  36.      isopen,    // is the band open?
  37.      priv_vars, // system memvars list
  38.     priv_vars2, // if FLD_EXPRESSION is broken into 2 strings
  39.      bandedit,  // word wrap off or on
  40.      bandgrp,   // GROUP id for bands
  41.      bandhgt,   // band row position plus height plus one
  42.      bandlen2,  // length of page header (0 if band is closed)
  43.      bandlen50, // length of detail band        "
  44.    bandspacing, // spacing on detail band
  45.      bandlen98, // length of page footer        "
  46.  bandspacing98, // spacing on footer band
  47.      bandtype,  // type of band ie. page footer, report intro, etc.
  48.  band_previous, // previous bandtype
  49.      length,    // length of field or text
  50.      maxgrp,    // maximum number of bands
  51.      isrepo,    // is there report intro/summary bands
  52.      maxrow,    // maximum row
  53.      nextrow,   // next row when looking ahead ie. ++<cursor>
  54. current_column, // current text or field plus length
  55.      bsrv,      // beginning of band suppress repeated value
  56.      xsrv,      // current suppress repeated value var
  57.      xsum,      // current "noname" summary field
  58.      xxsum,     // subset of either an average, std. deviation or variance
  59.      samerow,   // flag set for items occuring on the same row
  60.      bandrow,   // band row plus one
  61.  first_combine, // text or field is the first in the chain of combined data
  62.      combine,   // combine fields flag
  63.  suppress_line, // if the text "Page no." appears first on the line
  64.   previous_row, // previous elements' row
  65.     pre_type,   // previous element type was field or text
  66.    inner_loop,  // elements inside the band encountered
  67.   optl_heading, // flag to test whether optional heading has been output
  68. is_rintro_open, // is the Report Intro band open
  69.  is_rsumm_open, // is the Report Summary band open
  70. number_of_open_group_intros,   // none open, Grphead procedure is suppressed
  71. number_of_open_group_summarys, // none open, Grpfoot procedure is suppressed
  72. is_page_header_open, // if Page Header band is open
  73. number_of_reset_on_page, // summary fields reset on page
  74. number_of_fld_suppress,  // suppressed fields
  75. intro_band_one_height,   // footer widow checking for
  76. intro_band_two_height,   // dBASE III PLUS reports
  77. number_of_word_wrap_bands,
  78. number_of_group_footer_fields,
  79. current_group_footer_field,
  80. number_of_begin_new_pages
  81. ;
  82.  default_drive = STRSET(_defdrive);
  83.  rptname = FRAME_PATH + NAME;
  84.  if not FILEOK(rptname) then
  85.    if FILEDRIVE(NAME) || !default_drive then
  86.      rptname=NAME;
  87.    else
  88.      rptname=default_drive + ":" + NAME;
  89.    endif
  90.  endif
  91.  
  92.  if not CREATE(rptname+".FRG") then;
  93.    PAUSE(fileroot(rptname)+".FRG"+read_only+any_key);
  94.    return 0;
  95.  endif
  96. }
  97. {bandrow=0;
  98.  bsrv=0;
  99.  combine=0;
  100.  current_column=0;
  101.  first_combine=1;
  102.  isopen=0;
  103.  maxrow=0;
  104.  nextrow=0;
  105.  optl_heading=0;
  106.  previous_row=0;
  107.  pre_type=0;
  108.  samerow=0;
  109.  xsrv=0;
  110.  xsum=0;
  111.  xxsum=0;
  112. }
  113. * Program............: {rptname}.FRG
  114. * Date...............: {LTRIM(SUBSTR(DATE(),1,8))}
  115. * Versions...........: dBASE IV, Report {FRAME_VER}
  116. *
  117. * Notes:
  118. * ------
  119. * Prior to running this procedure with the DO command
  120. * it is necessary use LOCATE because the CONTINUE
  121. * statement is in the main loop.
  122. *
  123. *-- Parameters
  124. PARAMETERS gl_noeject, gl_plain, gl_summary, gc_heading, gc_extra
  125. ** The first three parameters are of type Logical.
  126. ** The fourth parameter is a string.  The fifth is extra.
  127. PRIVATE _peject\
  128. {if dBASE_III_PLUS == 2 then}
  129. , _plength, _ploffset\
  130. {endif}
  131. , _wrap
  132.  
  133. *-- Test for no records found
  134. IF EOF() .OR. .NOT. FOUND()
  135.    RETURN
  136. ENDIF
  137.  
  138. *-- turn word wrap mode off
  139. _wrap=.F.
  140.  
  141. {
  142.  isrepo=0;
  143.  is_rintro_open=0;
  144.  bandlen2=0;
  145.  is_page_header_open=0;
  146.  bandlen50=0;
  147.  number_of_begin_new_pages=0;
  148.  number_of_group_footer_fields=0;
  149.  number_of_open_group_summarys=0;
  150.  number_of_word_wrap_bands=0;
  151.  bandlen98=0;
  152.  bandspacing=0;
  153.  bandspacing98=0;
  154.  is_rsumm_open=0;
  155.  intro_band_one_height=0;
  156.  intro_band_two_height=0;
  157.  foreach BAND_ELEMENT k
  158.  
  159.    if BAND_BANDEDIT then ++number_of_word_wrap_bands; endif
  160.  
  161.    if BAND_NEWPAGE then ++number_of_begin_new_pages; endif
  162.  
  163.    case BAND_BANDTYPE of
  164.    Report_Intro:
  165.      isrepo=1;
  166.      if BAND_OPENFLG then is_rintro_open = 1; endif
  167. //
  168.    Page_Header:
  169.      if BAND_OPENFLG then
  170.        is_page_header_open = 1;
  171.        bandlen2=BAND_HEIGHT;
  172.      endif
  173. //
  174.    Group_Intro:
  175.      if dBASE_III_PLUS == 2 then
  176.        if GROUP == 4 then intro_band_one_height = BAND_HEIGHT; endif
  177.        if GROUP == 5 then intro_band_two_height = BAND_HEIGHT; endif
  178.      endif
  179. //
  180.    Detail:
  181.      if BAND_OPENFLG then bandlen50=BAND_HEIGHT; endif
  182.      if BAND_SPACING then
  183.        bandspacing=BAND_SPACING;
  184.      endif
  185. //
  186.    Group_Summary:
  187.      if BAND_OPENFLG then ++number_of_open_group_summarys; endif
  188. //
  189.    Page_Footer:
  190.      if BAND_OPENFLG then bandlen98=BAND_HEIGHT; endif
  191.      if BAND_SPACING then
  192.        bandspacing98=BAND_SPACING;
  193.      endif
  194. //
  195.    Report_Summary:
  196.      if BAND_OPENFLG then is_rsumm_open = 1; endif
  197.    endcase
  198.  next k;
  199.  if demo_version then ++bandlen98; endif
  200.  
  201.  if number_of_open_group_summarys || is_rsumm_open || bandlen98 then
  202.    foreach FLD_ELEMENT k
  203.      if GROUP > 50 then
  204.        d=0;
  205.        case FLD_FIELDTYPE of
  206.        Tabl_data: d=1;
  207.        Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
  208.        Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
  209.        endcase
  210.        if d then
  211.          ++number_of_group_footer_fields;
  212.        endif
  213.      endif
  214.    next k;
  215.  endif
  216. }
  217. IF _plength < {bandlen2+bandlen98+2}
  218.    SET DEVICE TO SCREEN
  219.    DEFINE WINDOW gw_report FROM 7,17 TO 11,62 DOUBLE
  220.    ACTIVATE WINDOW gw_report
  221.    @ 0,1 SAY "{increase_page}"
  222.    @ 2,1 SAY "{any_key}"
  223.    x=INKEY(0)
  224.    DEACTIVATE WINDOW gw_report
  225.    RELEASE WINDOW gw_report
  226.    RETURN
  227. ENDIF
  228.  
  229. _plineno=0          && set lines to zero
  230. {if dBASE_III_PLUS == 2 then}
  231. *-- dBASE III PLUS report setup
  232. _peject=\
  233. {case PRINT_NEW_PAGE of}
  234. {0:}"AFTER"
  235. {1:}"BEFORE"
  236. {2:}"BOTH"
  237. {3:}"NONE"
  238. {endcase}
  239. _plength={PRINT_PAGE_LENGTH}
  240. _ploffset={nul2zero(PRINT_LEFT_OFFSET)}
  241.  
  242. {endif}
  243. {if dBASE_III_PLUS == 2 then}
  244. *-- PLAIN option to screen only
  245. IF gl_plain
  246.    IF SET("PRINT") = "OFF" .AND. SET("ALTERNATE") = "OFF"
  247.       gl_noeject=.T.
  248.    ENDIF
  249. ENDIF
  250.  
  251. {endif}
  252. *-- NOEJECT parameter
  253. IF gl_noeject
  254.    IF _peject="BEFORE"
  255.       _peject="NONE"
  256.    ENDIF
  257.    IF _peject="BOTH"
  258.       _peject="AFTER"
  259.    ENDIF
  260. ENDIF
  261.  
  262. *-- Set-up environment
  263. ON ESCAPE DO prnabort
  264. IF SET("TALK")="ON"
  265.    SET TALK OFF
  266.    gc_talk="ON"
  267. ELSE
  268.    gc_talk="OFF"
  269. ENDIF
  270. gc_space=SET("SPACE")
  271. SET SPACE OFF
  272. gc_time=TIME()      && system time for predefined field
  273. gd_date=DATE()      && system date  "    "    "     "
  274. gl_fandl=.F.        && first and last page flag
  275. gl_prntflg=.T.      && Continue printing flag
  276. gl_widow=.T.        && flag for checking widow bands
  277. gn_length=LEN(gc_heading)  && store length of the HEADING
  278. gn_level=2          && current band being processed
  279. gn_page=_pageno     && grab current page number
  280. gn_pspace=_pspacing && get current print spacing
  281.  
  282. {x=0;
  283.  if number_of_group_footer_fields then
  284.    current_group_footer_field=1;
  285.    x=1;}
  286. *-- Initialize group footer field variables
  287. {  do while x <= number_of_group_footer_fields}
  288. r_foot{x}=.F.
  289. {    ++x;
  290.    enddo
  291.  endif
  292. }
  293.  
  294. {x=0;}
  295. {foreach FLD_ELEMENT k}
  296. //
  297. // Reset Summary (on page) and Suppress repeated values
  298. //
  299. {if FLD_FIELDTYPE == Summ_data && FLD_RESET == 1 then
  300.    ++number_of_reset_on_page
  301.  endif}
  302. {if FLD_SUPPRESS then ++number_of_fld_suppress endif}
  303. //
  304. // only if there is a fieldname assigned to the calculated field
  305. //
  306. {if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
  307. {  if !x then}
  308. *-- Initialize calculated variables.
  309. {  endif}
  310. {FLD_FIELDNAME}=\
  311. {case FLD_VALUE_TYPE of}
  312. {68: // Date   }CTOD("  /  /  ")
  313. {70: // Float  }FLOAT(0)
  314. {76: // Logical}.F.
  315. {78: // Numeric}0
  316. {otherwise:}""
  317. {endcase}
  318. {  ++x;}
  319. {endif}
  320. {next k;}
  321.  
  322. *-- Set up procedure for page break
  323. gn_atline=_plength - \
  324. {
  325. // Page footer set to default spacing?
  326.  if !bandspacing98 then
  327.  
  328. // Detail band set to default?
  329.    if !bandspacing then
  330.  
  331. // Page footer height greater than 1?
  332.      if bandlen98 > 1 then
  333. }
  334. (_pspacing * {bandlen98} + 1)
  335. {    else}
  336. {      if bandlen98 then}
  337. (_pspacing + 1)
  338. {      else}
  339. 1
  340. {      endif
  341.      endif
  342.  
  343. // Detail band is not default
  344.    else
  345.      bandspacing * bandlen98 +1}
  346.  
  347. {  endif
  348.  
  349. // Page footer is not default
  350.  else
  351.    bandspacing98 * bandlen98 +1}
  352.  
  353. {endif}
  354. ON PAGE AT LINE gn_atline EJECT PAGE
  355.  
  356. *-- Print Report
  357.  
  358. PRINTJOB
  359.  
  360. {if number_of_begin_new_pages then}
  361. gl_newpage=.T.      && ok to begin band on new page
  362.  
  363. {endif}
  364. {
  365.  x=1;  // to obtain number of group bands
  366.  number_of_open_group_intros=0;
  367.  
  368.  foreach BAND_ELEMENT k
  369. //
  370.    if BAND_BANDTYPE == Group_Intro then
  371.      if x == 1 then}
  372. *-- Initialize group break vars.
  373. {    endif
  374.      if BAND_OPENFLG then ++number_of_open_group_intros; endif}
  375. //
  376. {case BAND_GROUPTYPE of}
  377. {1: // by field}
  378. {// initialize Group by field variable}
  379. r_mvar{GROUP}=\
  380. {      if AT(">",BAND_GFIELD) then  // Check for ALIAS}
  381. {SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
  382.  
  383. {      else}
  384. {BAND_GFIELD}
  385.  
  386. {      endif}
  387. //
  388. {3: // by record count}
  389. {// initialize Group by record variable}
  390. r_mvar{GROUP}=1
  391. //
  392. {otherwise: // by expression}
  393. {// initialize Group by expression variable}
  394. r_mvar{GROUP}=\
  395. {foreach BAND_EXPRESSION fcursor in k}
  396. {BAND_EXPRESSION}
  397. {next}
  398.  
  399. //
  400. {endcase}
  401. {    ++x;
  402.    endif
  403.    if BAND_BANDTYPE == Detail then exit endif
  404.  next k;}
  405. {maxgrp=x+2;}
  406. {if x > 1 then}
  407.  
  408. {endif}
  409. {x=0;}
  410. {foreach FLD_ELEMENT k}
  411. {  if FLD_FIELDTYPE == Summ_data then}
  412. {    if !x then}
  413. *-- Initialize summary variables.
  414. {    endif}
  415. {    ++x;}
  416. //
  417. // standard deviation or variance?
  418. //
  419. {    if !FLD_FIELDNAME then}
  420. {      ++xsum;}
  421. {      priv_vars="r_msum"+STR(xsum);}
  422. {    else}
  423. {      priv_vars=FLD_FIELDNAME;}
  424. {    endif}
  425. {    if FLD_OPERATION > 4 then}
  426. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
  427. r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  428. // DECLARE {priv_vars}[5]
  429. // STORE 0 TO {priv_vars}[3]
  430. // STORE 0 TO {priv_vars}[1],{priv_vars}[2],{priv_vars}[4],{priv_vars}[5]
  431. {    else}
  432. {      case FLD_OPERATION of}
  433. {      0: // Average}
  434. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  435. // DECLARE {priv_vars}[3]
  436. // STORE 0 TO {priv_vars}[1]
  437. // STORE 0 TO {priv_vars}[2],{priv_vars}[3]
  438. {      1: // Count}
  439. {priv_vars}=0
  440. {      otherwise: // Max, Min or Sum}
  441. {priv_vars}=\
  442. {        if FLD_OPERATION == 3 then // Minimum}
  443. {FLD_SUMFIELD}
  444.  
  445. {        else}
  446. 0
  447. {        endif}
  448. {      endcase}
  449. {    endif}
  450. {  endif}
  451. {next k;}
  452. {xsum=0; xxsum=0;}
  453. {if x then}
  454.  
  455. {endif}
  456. {x=0;  // to offset each suppress repeated value variable}
  457. //
  458. {foreach FLD_ELEMENT k}
  459. //
  460. // suppress repeated values?
  461. //
  462. {if FLD_SUPPRESS then}
  463. {  if !x then}
  464. *-- Initialize suppress repeated value variables.
  465. {  endif}
  466. {++x;}
  467. r_msrv{x}=\
  468. {case FLD_VALUE_TYPE of}
  469. {68: // Date   }CTOD("  /  /  ")
  470. {70: // Float  }FLOAT(0)
  471. {76: // Logical}.NOT. \
  472. {  if FLD_FIELDNAME then}
  473. {FLD_FIELDNAME}
  474.  
  475. {  else}
  476. {    foreach FLD_EXPRESSION fcursor in k}
  477. {FLD_EXPRESSION}
  478. {    next}
  479.  
  480. {  endif}
  481. {78: // Numeric}0
  482. {otherwise:}""
  483. {endcase}
  484. {endif}
  485. {next k;}
  486. {if x then}
  487.  
  488. {endif}
  489. //
  490. {x=0;}
  491. {foreach FLD_ELEMENT k}
  492. //
  493. // only if there is a fieldname assigned to the calculated field
  494. //
  495. {if FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
  496. {  if !x then}
  497. *-- Assign initial values to calculated variables.
  498. {  endif}
  499. {FLD_FIELDNAME}=\
  500. {foreach FLD_EXPRESSION fcursor in k}
  501. {FLD_EXPRESSION}
  502. {next}
  503.  
  504. {  ++x;}
  505. {endif}
  506. {next k;}
  507. {if x then}
  508.  
  509. {endif}
  510. {x=0;}
  511. {foreach FLD_ELEMENT k}
  512. {  if FLD_FIELDTYPE == Summ_data then}
  513. {    if !FLD_FIELDNAME then}
  514. {      ++xsum;}
  515. {    endif}
  516. {    if FLD_OPERATION == 2 || FLD_OPERATION == 3 then}
  517. {      if !x then}
  518. *-- Initialize min/max summary variables again,
  519. *-- in case it's based on a calculated field.
  520. {      endif}
  521. {      ++x;}
  522. {      if !FLD_FIELDNAME then}
  523. {        priv_vars="r_msum"+STR(xsum);}
  524. {      else}
  525. {        priv_vars=FLD_FIELDNAME;}
  526. {      endif}
  527. {      priv_vars}={FLD_SUMFIELD}
  528. {    endif}
  529. {  endif}
  530. {next k;}
  531. {xsum=0;}
  532. {if x then}
  533.  
  534. {endif}
  535. {if isrepo && is_rintro_open then}
  536. {  if not FRAME_PAGEHEADINGS then}
  537. DO Rintro
  538.  
  539. *-- reset page number in case report intro spanned two pages
  540. _pageno=gn_page
  541.  
  542. {  endif}
  543. {endif}
  544. IF gl_plain
  545.    ON PAGE AT LINE gn_atline DO Pgplain
  546. ELSE
  547.    ON PAGE AT LINE gn_atline DO Pgfoot
  548. ENDIF
  549.  
  550. {if is_page_header_open || (is_rintro_open && FRAME_PAGEHEADINGS)
  551.  || number_of_open_group_intros then}
  552. DO Pghead
  553.  
  554. {endif}
  555. gl_fandl=.T.        && first physical page started
  556.  
  557. {if isrepo && is_rintro_open then}
  558. {  if FRAME_PAGEHEADINGS then}
  559. DO Rintro
  560. {    if number_of_begin_new_pages then}
  561. gl_newpage=.F.
  562. {    endif}
  563.  
  564. {  endif}
  565. {endif}
  566. {if maxgrp > 3 && number_of_open_group_intros then}
  567. DO Grphead
  568.  
  569. {endif}
  570. *-- File Loop
  571. DO WHILE FOUND() .AND. .NOT. EOF() .AND. gl_prntflg
  572. //
  573. // If there are group bands
  574. // set up the CASE structure to test
  575. // the group band values
  576. //
  577. {if maxgrp > 3 &&
  578.  (number_of_open_group_intros || number_of_open_group_summarys) then}
  579.    DO CASE
  580. {  foreach BAND_ELEMENT k}
  581. {    if BAND_BANDTYPE == Group_Intro then}
  582. //
  583. // Group by field
  584. //
  585. {      if BAND_GFIELD then}
  586.    CASE .NOT. (\
  587. {        if AT(">",BAND_GFIELD) then  // Check for ALIAS}
  588. {SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
  589. {        else}
  590. {BAND_GFIELD}
  591. {        endif}
  592.  = r_mvar{GROUP})
  593. {      endif}
  594. //
  595. // Group by expression
  596. //
  597. {      if BAND_EXPRESSION then}
  598.    CASE .NOT. (\
  599. {foreach BAND_EXPRESSION fcursor in k}
  600. {BAND_EXPRESSION}
  601. {next}
  602.  = r_mvar{GROUP})
  603. {      endif}
  604. //
  605. // Group by record count
  606. //
  607. {      if BAND_GROUP_REC then}
  608.    CASE r_mvar{GROUP} > {BAND_GROUP_REC}
  609. {      endif}
  610.       gn_level={GROUP}
  611. {    endif}
  612. {  next k;}
  613.    OTHERWISE
  614.       gn_level=0
  615.    ENDCASE
  616.    *-- test whether an expression didn't match
  617.    IF gn_level <> 0
  618. {  if number_of_open_group_summarys then}
  619.       DO Grpfoot WITH 100-gn_level
  620. {  endif}
  621.       DO Grpinit
  622.    ENDIF
  623. {  if number_of_open_group_intros then}
  624.    *-- Repeat group intros
  625.    IF gn_level <> 0
  626.       DO Grphead
  627.    ENDIF
  628. {  endif}
  629. {endif}
  630. {LMARG(4);}
  631. DO Upd_Vars
  632. {if bandlen50 then}
  633. *-- Detail lines
  634. IF .NOT. gl_summary
  635.    DO __Detail
  636. ENDIF
  637. {endif}
  638. {if number_of_group_footer_fields || is_rsumm_open || bandlen98 then
  639.    x=1;
  640.    foreach FLD_ELEMENT k
  641.      if GROUP > 50 then
  642.        d=0;
  643.        case FLD_FIELDTYPE of
  644.        Tabl_data: d=1;
  645.        Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
  646.        Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
  647.        endcase
  648.        if d then}
  649. r_foot{x}=\
  650. {        case FLD_FIELDTYPE of}
  651. {        Tabl_data:}
  652. {          FLD_FIELDNAME}
  653.  
  654. {        Calc_data:}
  655. {          FLD_FIELDNAME}
  656.  
  657. {        Pred_data:}
  658. RECNO()
  659. {        endcase}
  660. {        ++x;}
  661. {      endif
  662.      endif
  663.    next k;
  664.  endif}
  665. CONTINUE
  666. {if number_of_open_group_intros || number_of_open_group_summarys then}
  667. {foreach BAND_ELEMENT k}
  668. {  if BAND_BANDTYPE == Group_Intro then}
  669. //
  670. // increment any group by record count vars.
  671. //
  672. {    if BAND_GROUP_REC then}
  673. r_mvar{GROUP}=r_mvar{GROUP}+1
  674. {    endif}
  675. {  else}
  676. {    if BAND_BANDTYPE > Group_Intro then exit endif}
  677. {  endif}
  678. {next k;}
  679. {endif}
  680. {LMARG(1);}
  681. ENDDO
  682.  
  683. IF gl_prntflg
  684. //
  685. // If there are group bands
  686. //
  687. {if maxgrp > 3 then}
  688.    gn_level=3
  689. {  if number_of_open_group_summarys then}
  690.    DO Grpfoot WITH 97
  691. {  endif}
  692. {endif}
  693. //
  694. // Report summary?
  695. //
  696. {if isrepo && is_rsumm_open then}
  697.    DO Rsumm
  698. {endif}
  699. {  if bandlen98 then}
  700. {    if !is_rsumm_open then}
  701.    gl_fandl=.F.     && last page finished
  702. {    endif}
  703.    IF _plineno <= gn_atline
  704.       EJECT PAGE
  705.    ENDIF
  706. {  endif}
  707. ELSE
  708. {if isrepo && is_rsumm_open then}
  709. {  if maxgrp > 3 then}
  710.    gn_level=3
  711. {  endif}
  712.    DO Rsumm
  713. {endif}
  714.    DO Reset
  715.    RETURN
  716. ENDIF
  717.  
  718. ON PAGE
  719.  
  720. ENDPRINTJOB
  721.  
  722. DO Reset
  723. RETURN
  724. * EOP: {rptname}.FRG
  725. {x=0;
  726.  foreach BAND_ELEMENT k
  727.    if BAND_BANDTYPE > Group_Intro then exit endif
  728.    if BAND_BANDTYPE == Group_Intro then
  729.      if !x then}
  730.  
  731. *-- Determine height of group bands and detail band for widow checking
  732. FUNCTION Gheight
  733. PARAMETER Group_Band
  734. retval=0              && return value
  735. {    endif}
  736. IF Group_Band <= {GROUP}
  737.    retval = retval +\
  738. {    if BAND_HEIGHT > 1 then}
  739.  {BAND_HEIGHT}\
  740. {    endif}
  741. {    if !BAND_SPACING && !bandspacing then}
  742. {if BAND_HEIGHT > 1 then} *{endif} gn_pspace
  743. {    else
  744.        if !BAND_SPACING && bandspacing > 1 then}
  745. {if BAND_HEIGHT > 1 then} *{endif} {bandspacing}
  746. {      else
  747.          if BAND_SPACING > 1 then}
  748. {if BAND_HEIGHT > 1 then} *{endif} {BAND_SPACING}
  749. {        else}
  750. {          if BAND_HEIGHT < 2 then}
  751.  {BAND_HEIGHT}\
  752. {          endif}
  753.  
  754. {        endif
  755.        endif
  756.      endif}
  757. ENDIF
  758. {    ++x;
  759.    endif
  760.  next k;
  761.  if x then
  762.    if bandlen50 then}
  763. *-- add height of detail band
  764. retval = retval + \
  765. {    if !bandspacing then}
  766. {if bandlen50 > 1 then}{bandlen50} * {endif}gn_pspace
  767. {    else}
  768. {      if bandspacing > 1 then}
  769. {bandspacing*bandlen50}
  770.  
  771. {      else}
  772. {bandlen50}
  773.  
  774. {      endif
  775.      endif
  776.    endif}
  777. RETURN retval
  778. * EOP: Gheight
  779. {endif}
  780.  
  781. *-- Update summary fields and/or calculated fields in the detail band.
  782. PROCEDURE Upd_Vars
  783. {x=0;}
  784. {foreach FLD_ELEMENT k}
  785. //
  786. // Initialize calculated fields for Detail band
  787. //
  788. {  if GROUP == 50 && FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
  789. {FLD_FIELDNAME}=\
  790. {    foreach FLD_EXPRESSION fcursor in k}
  791. {FLD_EXPRESSION}
  792. {    next}
  793.  
  794. {  endif}
  795. //
  796. // Summary field?
  797. //
  798. {if FLD_FIELDTYPE == Summ_data then}
  799. {  if !FLD_FIELDNAME then}
  800. {    ++x;}
  801. {    priv_vars="r_msum"+STR(x);}
  802. {  else}
  803. {    priv_vars=FLD_FIELDNAME;}
  804. {  endif}
  805. *-- \
  806. {case FLD_OPERATION of}
  807. {0: // AVG}
  808. Average
  809. r_sum{++xxsum}=r_sum{xxsum}+1{tabto(40)}&& count
  810. // {priv_vars}[1]={priv_vars}[1]+1{tabto(40)}&& count
  811. r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}{tabto(40)}&& sum
  812. // {priv_vars}[2]={priv_vars}[2]+{FLD_SUMFIELD}{tabto(40)}&& sum
  813. {priv_vars}=r_sum{xxsum}/r_sum{xxsum-1}{tabto(40)}&& average
  814. // {priv_vars}[3]={priv_vars}[2]/{priv_vars}[1]{tabto(40)}&& average
  815. {1: // COUNT}
  816. Count
  817. {priv_vars}={priv_vars}+1
  818. {2: // MAX}
  819. Max
  820. IF {FLD_SUMFIELD} > {priv_vars}
  821.    {priv_vars}={FLD_SUMFIELD}
  822. ENDIF
  823. {3: // MIN}
  824. Min
  825. IF {FLD_SUMFIELD} < {priv_vars}
  826.    {priv_vars}={FLD_SUMFIELD}
  827. ENDIF
  828. {4: // SUM}
  829. Sum
  830. {priv_vars}={priv_vars}+{FLD_SUMFIELD}
  831. {otherwise: // STD or VAR}
  832. {if FLD_OPERATION == 5 then}
  833. Std deviation
  834. {else}
  835. Variance
  836. {endif}
  837. r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}^2\
  838. {tabto(40)}&& sum of squares
  839. // {priv_vars}[1]={priv_vars}[1]+{FLD_SUMFIELD}^2\
  840. // {tabto(40)}&& sum of squares
  841. r_sum{++xxsum}=r_sum{xxsum}+{FLD_SUMFIELD}\
  842. {tabto(40)}&& sum
  843. // {priv_vars}[2]={priv_vars}[2]+{FLD_SUMFIELD}\
  844. // {tabto(40)}&& sum
  845. r_sum{++xxsum}=r_sum{xxsum}+1\
  846. {tabto(40)}&& count
  847. // {priv_vars}[3]={priv_vars}[3]+1\
  848. // {tabto(40)}&& count
  849. r_sum{++xxsum}=r_sum{xxsum-2}/r_sum{xxsum-1}\
  850. {tabto(40)}&& average
  851. // {priv_vars}[4]={priv_vars}[2]/{priv_vars}[3]\
  852. // {tabto(40)}&& average
  853. *-- variance
  854. {priv_vars}=\
  855. (r_sum{xxsum-3}+r_sum{xxsum-1}*(r_sum{xxsum}^2);
  856.     -(2*r_sum{xxsum}*r_sum{xxsum-2}))/r_sum{xxsum-1}
  857. // {priv_vars}[5]=\
  858. // ({priv_vars}[1]+{priv_vars}[3]*({priv_vars}[4]^2);
  859. //    -(2*{priv_vars}[4]*{priv_vars}[2]))/{priv_vars}[3]
  860. {if FLD_OPERATION == 5 then}
  861. {priv_vars}=SQRT({priv_vars})\
  862. {tabto(40)}&& std deviation
  863. // {priv_vars}[5]=SQRT({priv_vars}[5])\
  864. // {tabto(40)}&& std deviation
  865. {endif}
  866. {endcase}
  867. {endif}
  868. {next k;}
  869. {xxsum=0;}
  870. RETURN
  871. * EOP: Upd_Vars
  872.  
  873. *-- Set flag to get out of DO WHILE loop when escape is pressed.
  874. PROCEDURE prnabort
  875. gl_prntflg=.F.
  876. RETURN
  877. * EOP: prnabort
  878.  
  879. {if number_of_open_group_intros || number_of_open_group_summarys then}
  880. *-- Reset group break variables.  Reinit summary
  881. *-- fields with reset set to a particular group band.
  882. PROCEDURE Grpinit
  883. {i=0;
  884.  x=0;}
  885. {foreach FLD_ELEMENT k}
  886. //
  887. // Summary field and reset on group?
  888. //
  889. {  if FLD_FIELDTYPE == Summ_data && FLD_RESET >= Each_Group then}
  890. {    if i && FLD_RESET > Each_Group && i != FLD_RESET then}
  891. {      i=0;
  892.        lmarg(1);}
  893. ENDIF
  894. {    endif}
  895. {    if FLD_RESET > Each_Group && i != FLD_RESET then}
  896. IF gn_level <= {FLD_RESET}
  897. {      i=FLD_RESET;
  898.        lmarg(4);}
  899. {    endif}
  900. {    if !FLD_FIELDNAME then}
  901. {      ++x;}
  902. {      priv_vars="r_msum"+STR(x);}
  903. {    else}
  904. {      priv_vars=FLD_FIELDNAME;}
  905. {    endif}
  906. //
  907. // standard deviation or variance?
  908. //
  909. {    if FLD_OPERATION > 4 then}
  910. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
  911. r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  912. // STORE 0 TO {priv_vars}[3]
  913. // STORE 0 TO {priv_vars}[1],{priv_vars}[2],\
  914. // {priv_vars}[4],{priv_vars}[5]
  915. {    else}
  916. {      case FLD_OPERATION of}
  917. {      0: // Average}
  918. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  919. // STORE 0 TO {priv_vars}[1]
  920. // STORE 0 TO {priv_vars}[2],{priv_vars}[3]
  921. {      1: // Count}
  922. {priv_vars}=0
  923. {      otherwise: // Min, Max or Sum}
  924. {priv_vars}=\
  925. {        if FLD_OPERATION == 3 then // Minimum}
  926. {FLD_SUMFIELD}
  927.  
  928. {        else}
  929. 0
  930. {        endif}
  931. {      endcase}
  932. {    endif}
  933. {  endif}
  934. {next k;}
  935. {xxsum=0;}
  936. {if i then
  937.    i=0;
  938.    lmarg(1);}
  939. ENDIF
  940. {endif}
  941. {foreach BAND_ELEMENT k}
  942. {  if BAND_BANDTYPE == Group_Intro then}
  943. //
  944. // Reset Group break vars on group intro bands
  945. //
  946. IF gn_level <= {GROUP}
  947. //
  948. {    lmarg(4);}
  949. {    if BAND_GFIELD then}
  950. r_mvar{GROUP}=\
  951. {      if AT(">",BAND_GFIELD) then  // Check for ALIAS}
  952. {SUBSTR(BAND_GFIELD,AT(">",BAND_GFIELD)+1)}
  953.  
  954. {      else}
  955. {BAND_GFIELD}
  956.  
  957. {      endif}
  958. {    endif}
  959. {    if BAND_GROUP_REC then}
  960. r_mvar{GROUP}=1
  961. {    endif}
  962. {    if BAND_EXPRESSION then}
  963. r_mvar{GROUP}=\
  964. {foreach BAND_EXPRESSION fcursor in k}
  965. {BAND_EXPRESSION}
  966. {next}
  967.  
  968. {    endif}
  969. {    lmarg(1);}
  970. ENDIF
  971. {  else}
  972. {    if BAND_BANDTYPE > Group_Intro then exit endif}
  973. {  endif}
  974. {next k;}
  975. RETURN
  976. * EOP: Grpinit
  977.  
  978. {endif}
  979. {if number_of_reset_on_page || number_of_fld_suppress then}
  980. *-- Reset summary fields (on page) and suppress repeated values.
  981. PROCEDURE Pageinit
  982. {i=0;}
  983. {x=0;}
  984. {foreach FLD_ELEMENT k}
  985. {  if FLD_SUPPRESS then}
  986. {    ++x;}
  987. r_msrv{x}=\
  988. {    case FLD_VALUE_TYPE of}
  989. {    68: // Date}CTOD("  /  /  ")
  990. {    70: // Float}FLOAT(0)
  991. {    76: // Logical}.NOT. \
  992. {      if FLD_FIELDNAME then}
  993. {FLD_FIELDNAME}
  994.  
  995. {      else}
  996. {        foreach FLD_EXPRESSION fcursor in k}
  997. {FLD_EXPRESSION}
  998. {        next}
  999.  
  1000. {      endif}
  1001. {    78: // Numeric}0
  1002. {    otherwise:}""
  1003. {    endcase}
  1004. {  endif}
  1005. {  if FLD_FIELDTYPE == Summ_data && FLD_RESET == Each_Page then}
  1006. {    if !FLD_FIELDNAME then}
  1007. {      ++i;}
  1008. {      priv_vars="r_msum"+STR(i);}
  1009. {    else}
  1010. {      priv_vars=FLD_FIELDNAME;}
  1011. {    endif}
  1012. {    if FLD_OPERATION > 4 then}
  1013. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},\
  1014. r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  1015. // STORE 0 TO {priv_vars}[3]
  1016. // STORE 0 TO {priv_vars}[1],{priv_vars}[2],\
  1017. // {priv_vars}[4],{priv_vars}[5]
  1018. {    else}
  1019. {      case FLD_OPERATION of}
  1020. {      0: // Average}
  1021. STORE 0 TO r_sum{++xxsum},r_sum{++xxsum},{priv_vars}
  1022. // STORE 0 TO {priv_vars}[1]
  1023. // STORE 0 TO {priv_vars}[2],{priv_vars}[3]
  1024. {      1: // Count}
  1025. {priv_vars}=0
  1026. {      otherwise: // Min,Max or Sum}
  1027. {priv_vars}=\
  1028. {        if FLD_OPERATION == 3 then // Minimum}
  1029. {FLD_SUMFIELD}
  1030.  
  1031. {        else}
  1032. 0
  1033. {        endif}
  1034. {      endcase}
  1035. {    endif}
  1036. {  endif}
  1037. {next k;}
  1038. {xxsum=0;}
  1039. RETURN
  1040. * EOP: Pageinit
  1041.  
  1042. {endif}
  1043. {if maxgrp > 3 &&
  1044.  (number_of_open_group_intros || number_of_open_group_summarys) then}
  1045. {  if number_of_open_group_intros then}
  1046. *-- Process Group Intro bands during group breaks
  1047. PROCEDURE Grphead
  1048. IF EOF()
  1049.    RETURN
  1050. ENDIF
  1051. PRIVATE _pspacing
  1052. {if bandspacing then}
  1053. _pspacing={bandspacing}
  1054. {else}
  1055. _pspacing=gn_pspace
  1056. {endif}
  1057. gl_widow=.T.         && enable widow checking
  1058. {  endif}
  1059. {  if dBASE_III_PLUS == 2 && !number_of_open_group_summarys then}
  1060. IF gn_level > 3
  1061.    ?
  1062. ENDIF
  1063. {  endif}
  1064. {foreach BAND_ELEMENT k}
  1065. {  case BAND_BANDTYPE of}
  1066. {  Group_Intro:}
  1067. {    if BAND_OPENFLG then}
  1068. IF gn_level <= {GROUP}
  1069.    DO Head{GROUP}
  1070. ENDIF
  1071. {    endif}
  1072. {  Detail:}
  1073. {    if number_of_open_group_intros then}
  1074. gn_level=0
  1075. RETURN
  1076. * EOP: Grphead.PRG
  1077.  
  1078. {    endif}
  1079. {    if number_of_open_group_summarys then}
  1080. *-- Process Group Summary bands during group breaks
  1081. PROCEDURE Grpfoot
  1082. PARAMETER ln_level
  1083. {    endif}
  1084. {  Group_Summary:}
  1085. {    if BAND_OPENFLG then}
  1086. IF ln_level >= {GROUP}
  1087.    DO Foot{GROUP}
  1088. ENDIF
  1089. {    endif}
  1090. {  Page_Footer:}
  1091. {    if number_of_open_group_summarys then}
  1092. RETURN
  1093. * EOP: Grpfoot.PRG
  1094.  
  1095. {    endif}
  1096. {  endcase}
  1097. {next k;}
  1098. {endif}
  1099. {bandtype=99;}
  1100. //
  1101. {foreach ELEMENT ecursor}
  1102. {  inner_loop=0;}
  1103. {  pre_type=0;}
  1104. //
  1105. // List type is a BAND?
  1106. //
  1107. {if ELEMENT_TYPE == @Band_Element then}
  1108. {  band_previous=bandtype;
  1109.    bandtype=BAND_BANDTYPE;}
  1110. //
  1111. // reset samerow to zero if set and output a carriage return
  1112. //
  1113. {  if samerow then}
  1114. {    samerow=0;}
  1115. //
  1116. {  endif}
  1117. {  combine=0;}
  1118. {  first_combine=1;}
  1119. //
  1120. // Output carriage returns for dBASE report to handle blank lines
  1121. //
  1122. {  nextline2:}
  1123. {  if maxrow < bandhgt then}
  1124. {    if isopen then}
  1125. ?
  1126. {    endif}
  1127. {    ++maxrow;}
  1128. {    goto nextline2;}
  1129. {  endif}
  1130. //
  1131. // beyond the first band?
  1132. //
  1133. {  if band_previous != 99 then}
  1134. //
  1135. {    if number_of_begin_new_pages then
  1136.        if band_previous == Group_Intro
  1137.        || band_previous == Detail
  1138.        || band_previous == Group_Summary then}
  1139. gl_newpage=.F.
  1140. {      endif}
  1141. {    endif}
  1142. {    if band_previous == Page_Header || band_previous == Page_Footer
  1143.  || isopen then}
  1144. {      case band_previous of}
  1145. {      Page_Header:}
  1146. //
  1147. {        if suppress_line then
  1148.      suppress_line=0;}
  1149. //
  1150. {          lmarg(1);}
  1151. ENDIF
  1152. {        endif}
  1153. //
  1154. {        if isopen || (is_rintro_open && FRAME_PAGEHEADINGS)
  1155.          || number_of_open_group_intros then}
  1156. //
  1157. // Insert heading code for no page number
  1158. //
  1159. {          if !optl_heading then}
  1160. *-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
  1161. IF .NOT. gl_plain .AND. gn_length > 0
  1162.    ?? gc_heading FUNCTION "I;V"+LTRIM(STR(_rmargin-_lmargin))
  1163.    ?
  1164. ENDIF
  1165. {            optl_heading=1;}
  1166. {          endif}
  1167. //
  1168. RETURN
  1169. * EOP: Pghead
  1170. {        endif}
  1171. {      Report_Intro:}
  1172. RETURN
  1173. * EOP: Rintro
  1174. {      Group_Intro:}
  1175. RETURN
  1176. {      Detail:}
  1177. RETURN
  1178. * EOP: __Detail
  1179. {      Group_Summary:}
  1180. {if dBASE_III_PLUS == 2 then}
  1181. IF ln_level < 9{if GROUP == 96 then}6{else}7{endif}
  1182.    ?
  1183. ENDIF
  1184. {endif}
  1185. RETURN
  1186. {      Report_Summary:}
  1187. gl_fandl=.F.        && last page finished
  1188. ?
  1189. RETURN
  1190. * EOP: Rsumm
  1191. {      Page_Footer:}
  1192. {        finish_page_footer();}
  1193. {      endcase}
  1194. {    endif}
  1195.  
  1196. {  endif}
  1197. //
  1198. // capture band attributes
  1199. // -----------------------
  1200. // bandrow and maxrow for row position
  1201. // bandedit for word wrap band
  1202. // isopen for band open or closed
  1203. //
  1204. {  if Row_Positn then
  1205.      bandhgt=Row_Positn+BAND_HEIGHT+1;
  1206.      bandrow=Row_Positn+1;
  1207.      maxrow=Row_Positn+1;
  1208.    else
  1209.      bandhgt=BAND_HEIGHT+1;
  1210.      bandrow=1;
  1211.      maxrow=1;
  1212.    endif
  1213. }
  1214. {  bandedit=BAND_BANDEDIT;}
  1215. {  bandgrp=GROUP;}
  1216. {  bsrv=xsrv;}
  1217. {  isnew=1;}
  1218. {  isopen=BAND_OPENFLG;}
  1219. //
  1220. {  if BAND_BANDTYPE == Page_header || BAND_BANDTYPE == Page_Footer
  1221.    || BAND_OPENFLG then}
  1222. {    if BAND_BANDTYPE then}
  1223. PROCEDURE \
  1224. {    else}
  1225. {      if BAND_OPENFLG || (is_rintro_open && FRAME_PAGEHEADINGS)
  1226.        || number_of_open_group_intros then}
  1227. PROCEDURE \
  1228. {      endif}
  1229. {    endif}
  1230. {    case bandtype of}
  1231. {    Page_Header:}
  1232. {      if BAND_OPENFLG || (is_rintro_open && FRAME_PAGEHEADINGS)
  1233.        || number_of_open_group_intros then}
  1234. Pghead
  1235. {      endif}
  1236. {    Report_Intro:}
  1237. Rintro
  1238. {    Group_Intro:}
  1239. Head{GROUP}
  1240. {      if not BAND_INTROEACH then}
  1241. IF gn_level=1
  1242.    RETURN
  1243. ENDIF
  1244. {      endif}
  1245. {      if dBASE_III_PLUS == 2 && GROUP == 4 && 
  1246.        intro_band_one_height && intro_band_two_height then
  1247.          ++bandhgt;
  1248.        endif}
  1249. {    Detail:}
  1250. __Detail
  1251. {    Group_Summary:}
  1252. Foot{GROUP}
  1253. {      if dBASE_III_PLUS == 2 then}
  1254. ln_lines=IIF(ln_level < 97, \
  1255. {        case GROUP of
  1256.          96:}
  1257. {intro_band_one_height+intro_band_two_height+2}, \
  1258. {intro_band_one_height+intro_band_two_height+1})
  1259. {        95:}
  1260. {intro_band_two_height+2}, \
  1261. {intro_band_two_height+1})
  1262. {        endcase}
  1263. IF _plineno+ln_lines > gn_atline
  1264.    _plineno=gn_atline
  1265.    ?
  1266. ENDIF
  1267. {      endif}
  1268. {    Report_Summary:}
  1269. Rsumm
  1270. {      --bandhgt;}
  1271. {    Page_Footer:}
  1272. Pgfoot
  1273. PRIVATE _box{if isopen}, _pspacing{endif}
  1274. gl_widow=.F.         && disable widow checking
  1275. {      if isopen then}
  1276. _pspacing=1
  1277. ?
  1278. {      endif}
  1279. {      --bandhgt;}
  1280. {      if BAND_OPENFLG && BAND_HEIGHT then}
  1281. IF .NOT. gl_plain
  1282. {      endif}
  1283. {    endcase}
  1284. {  endif}
  1285. //
  1286. // is the band open?
  1287. // make system memvars PRIVATE
  1288. // only if the values change
  1289. //
  1290. {  if isopen then}
  1291. //
  1292. // BAND_NEWPAGE  - Begin band on new page:  No, Yes|
  1293. //
  1294. {    if BAND_NEWPAGE then}
  1295. IF .NOT. gl_newpage
  1296.    gl_newpage=.T.
  1297.    EJECT PAGE
  1298. ENDIF
  1299. {    endif}
  1300. //
  1301. // BAND_TEXTPITCH - Text pitch for band:  Pica, Elite, Condensed, Default|
  1302. //
  1303. {    if BAND_TEXTPITCH != 3 then}
  1304. IF SET("PRINT") = "ON" .AND. _ppitch <> \
  1305. {      case BAND_TEXTPITCH of}
  1306. {      0:}
  1307. "PICA"
  1308. {      1:}
  1309. "ELITE"
  1310. {      2:}
  1311. "CONDENSED"
  1312. {      3:}
  1313. "DEFAULT"
  1314. {      endcase}
  1315.    PRIVATE _ppitch
  1316.    _ppitch = \
  1317. {      case BAND_TEXTPITCH of}
  1318. {      0:}
  1319. "PICA"
  1320. {      1:}
  1321. "ELITE"
  1322. {      2:}
  1323. "CONDENSED"
  1324. {      3:}
  1325. "DEFAULT"
  1326. {      endcase}
  1327. ENDIF
  1328. {    endif}
  1329. //
  1330. // BAND_QUALITY - Quality pitch for band:  Yes, No|
  1331. //
  1332. {    if BAND_QUALITY < 2 then}
  1333. IF SET("PRINT") = "ON" .AND. {if !BAND_QUALITY then}.NOT. {endif}_pquality
  1334.    PRIVATE _pquality
  1335.    _pquality = \
  1336. {      if BAND_QUALITY then}
  1337. .F.
  1338. {      else}
  1339. .T.
  1340. {      endif}
  1341. ENDIF
  1342. {    endif}
  1343. //
  1344. // BAND_SPACING - Default, single, double or triple
  1345. //
  1346. {    if BAND_SPACING then}
  1347. IF _pspacing <> {BAND_SPACING}
  1348.    PRIVATE _pspacing
  1349.    _pspacing={BAND_SPACING}
  1350. ENDIF
  1351. {    endif}
  1352. //
  1353. // BAND_BANDEDIT - Wordwrap band:  Yes, No|
  1354. //
  1355. {    if number_of_word_wrap_bands then}
  1356. {      if BAND_BANDEDIT then}
  1357. PRIVATE _indent, _lmargin, _rmargin, _tabs
  1358. {      endif}
  1359. IF {   if BAND_BANDEDIT then}.NOT. {endif}_wrap
  1360.    PRIVATE _wrap
  1361.    _wrap = \
  1362. {      if BAND_BANDEDIT then}
  1363. .T.
  1364. {      else}
  1365. .F.
  1366. {      endif}
  1367. ENDIF
  1368. {    endif}
  1369. //
  1370. {    i=GROUP;}
  1371. //
  1372. // Initialize calculated fields
  1373. // in case they are used in the group break procedure
  1374. //
  1375. {    if BAND_BANDTYPE != Detail then}
  1376. {      foreach FLD_ELEMENT k}
  1377. {        if GROUP == i && FLD_FIELDTYPE == Calc_data && FLD_FIELDNAME then}
  1378. {FLD_FIELDNAME}=\
  1379. {          foreach FLD_EXPRESSION fcursor in k}
  1380. {FLD_EXPRESSION}
  1381. {          next}
  1382.  
  1383. {        endif}
  1384. {      next k;}
  1385. {    endif}
  1386. //
  1387. // Check for possible widow band
  1388. //
  1389. {    if BAND_BANDTYPE == Group_Intro then}
  1390. //
  1391. {      x=0;
  1392.        i=GROUP;
  1393.        foreach BAND_ELEMENT k
  1394. //
  1395. // GROUP >= i means current Group intro
  1396. //
  1397.          if k.BAND_OPENFLG && k.GROUP >= i then
  1398.            if k.BAND_BANDTYPE <= Detail then
  1399.              x=x+k.BAND_HEIGHT;
  1400.            else
  1401.              exit
  1402.            endif
  1403.          endif
  1404.        next k;
  1405. }
  1406. //
  1407. {      ni="";
  1408.        if x then
  1409.          if !BAND_SPACING && !bandspacing then
  1410.            ni=" * gn_pspace";
  1411.          else
  1412.            if !BAND_SPACING && bandspacing > 1 then
  1413.              ni=" * "+STR(bandspacing);
  1414.            else
  1415.              if BAND_SPACING > 1 then
  1416.                ni=" * "+STR(BAND_SPACING);
  1417.              endif
  1418.            endif
  1419.          endif
  1420.          if BAND_HEIGHT > 1 then
  1421.            a=STR(BAND_HEIGHT)+ni+" ";
  1422.          else
  1423.            if ni then
  1424.              a=SUBSTR(ni,4)+" ";
  1425.            else
  1426.              a="";
  1427.            endif
  1428.          endif
  1429.          if a then}
  1430. IF {a} < _plength
  1431. {        lmarg(4);}
  1432. IF (gl_widow .AND. _plineno+Gheight({GROUP}) > gn_atline + 1)\
  1433. {        if BAND_HEIGHT then}
  1434.  ;
  1435. .OR. (gl_widow .AND. _plineno+\
  1436. {          if BAND_HEIGHT > 1 then}
  1437. {BAND_HEIGHT}{ni}\
  1438. {          else}
  1439. {            if !BAND_SPACING then}
  1440. {              if ni then}
  1441. {SUBSTR(ni,4)}\
  1442. {              else}
  1443. 1\
  1444. {              endif}
  1445. {            else}
  1446. {BAND_SPACING}\
  1447. {            endif
  1448.            endif}
  1449.  > gn_atline)
  1450. {        else}
  1451.  
  1452. {        endif
  1453.          endif}
  1454.    EJECT PAGE
  1455. ENDIF
  1456. {        lmarg(1);}
  1457. ENDIF
  1458. {      endif}
  1459. {    endif}
  1460. //
  1461. {    ni="";
  1462.      if BAND_BANDTYPE == Detail then
  1463.        if BAND_HEIGHT then
  1464.          if !bandspacing then
  1465.            if BAND_HEIGHT > 1 then
  1466.              ni=STR(BAND_HEIGHT)+" * gn_pspace";
  1467.            else
  1468.              ni="gn_pspace";
  1469.            endif
  1470.          else
  1471.            if bandspacing > 1 then
  1472.              ni=STR(BAND_HEIGHT * BAND_SPACING);
  1473.            else
  1474.              if BAND_HEIGHT > 1 then
  1475.                ni=STR(BAND_HEIGHT);
  1476.              endif
  1477.            endif
  1478.          endif
  1479.          if ni then}
  1480. IF {ni} < _plength
  1481.    IF gl_widow .AND. _plineno+{ni} > gn_atline + 1
  1482.       EJECT PAGE
  1483.    ENDIF
  1484. ENDIF
  1485. {        endif
  1486.        endif
  1487.      endif}
  1488. {    if Row_Positn then previous_row=Row_Positn endif;}
  1489. {  endif}
  1490. {  loop}
  1491. {else}
  1492. {  ++count;}
  1493. {endif}
  1494. {do while ELEMENT_TYPE != @Band_Element && !eoc(ecursor)}
  1495. {  inner_loop=1;}
  1496. //
  1497. {  if FLD_SUPPRESS then}
  1498. {    ++xsrv;}
  1499. {  endif}
  1500. //
  1501. {  if FLD_HIDDEN || not isopen goto noprint endif}
  1502. //
  1503. // List type is TEXT or FIELD?
  1504. //
  1505. {  if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
  1506. {    if pre_type && maxrow == Row_Positn then}
  1507. {      samerow=1;}
  1508. {    else}
  1509. {      samerow=0;}
  1510. {      combine=0;}
  1511. {      first_combine=1;}
  1512. {    endif}
  1513. {  endif}
  1514. //
  1515. // Output carriage returns for dBASE report
  1516. //
  1517. {  if !bandedit then}
  1518. {    nextline1:}
  1519. {    if maxrow < Row_Positn then}
  1520. ?
  1521. {      ++maxrow;}
  1522. {      goto nextline1;}
  1523. {    endif}
  1524. {  else}
  1525. {    maxrow=Row_Positn;}
  1526. {  endif}
  1527. //
  1528. // Insert heading code for no page number
  1529. //
  1530. {    if !optl_heading && bandtype == Page_Header &&
  1531.      Row_Positn > bandrow+1 && !suppress_line then}
  1532. *-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
  1533. IF .NOT. gl_plain .AND. gn_length > 0
  1534.    ?? gc_heading FUNCTION "I;V"+LTRIM(STR(_rmargin-_lmargin))
  1535.    ?
  1536. ENDIF
  1537. {      optl_heading=1;}
  1538. {    endif}
  1539. //
  1540. {  pre_type=0;}
  1541. //
  1542. {  case ELEMENT_TYPE of}
  1543. {  @Text_Element:}
  1544. //
  1545. {    x=Col_Positn;}
  1546. {    i=LEN(Text_Item);}
  1547. {    ni=0;}
  1548. {    pre_type=1;}
  1549. {    if i == 237 then}
  1550. {      foreach Text_Item fcursor in ecursor}
  1551. {        if ni then}
  1552. {          i=i+LEN(Text_Item);}
  1553. {          temp=Text_Item;}
  1554. {        endif}
  1555. {        ++ni;}
  1556. {      next}
  1557. {    endif}
  1558. {    current_column=x+i;}
  1559. {    ++ecursor;}
  1560. {    nextrow=Row_Positn;}
  1561. {    if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
  1562. {      if current_column == Col_Positn && maxrow == Row_Positn then}
  1563. {        combine=1;}
  1564. {      else}
  1565. {        combine=0;}
  1566. {      endif}
  1567. {      if (bandtype == Page_Header || bandtype == Page_Footer) &&
  1568.        ELEMENT_TYPE == @Fld_Element && nextrow == maxrow then}
  1569. {        if FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE == 3 then}
  1570. {          --ecursor;}
  1571. {          if SUBSTR(UPPER(Text_Item),1,4) == "PAGE" then
  1572.              suppress_line=1;
  1573.            endif}
  1574. {          ++ecursor;}
  1575. {          if suppress_line then}
  1576. {            ++ecursor;}
  1577. {            if !eoc(ecursor) && Row_Positn == nextrow then}
  1578. {              suppress_line=2;}
  1579. {            endif}
  1580. {            --ecursor;}
  1581. {          endif}
  1582. {        endif}
  1583. {      endif}
  1584. {    endif}
  1585. {    --ecursor;}
  1586. //
  1587. {    if suppress_line == 1 &&
  1588.      (bandtype == Page_Header || bandtype == Page_Footer) then
  1589.        plainopt(ecursor);
  1590.      endif}
  1591. {    if isnew then}
  1592. {      isnew=0;}
  1593. ?? \
  1594. {    else}
  1595. {      if samerow then}
  1596. ?? \
  1597. {      else}
  1598. ?? \
  1599. {      endif}
  1600. {    endif}
  1601. {    if suppress_line == 2 then}
  1602. IIF(gl_plain,'' , \
  1603. {    endif}
  1604. {    if i > 70 then}
  1605. ;
  1606. {      seperate(Text_Item);}
  1607. {      if ni then}
  1608. + "{temp}";
  1609. {      endif}
  1610. {    else}
  1611. "{Text_Item}" \
  1612. {    endif}
  1613. {    if suppress_line == 2 then}
  1614. ) \
  1615. {      suppress_line=0;}
  1616. {    endif}
  1617. {  @Box_Element:}
  1618. DEFINE BOX FROM {nul2zero(BOX_LEFT)} TO {nul2zero(BOX_LEFT)+BOX_WIDTH-1} \
  1619. HEIGHT {BOX_HEIGHT} \
  1620. {    case BOX_TYPE of}
  1621. {    0: // Single}
  1622. SINGLE
  1623. {    1: // Double}
  1624. DOUBLE
  1625. {    2: // Defined}
  1626. CHR({BOX_SPECIAL_CHAR})
  1627. {    endcase}
  1628. {    nextrow=Row_Positn;}
  1629. {  @Page_Element:}
  1630. EJECT PAGE
  1631. {  @Para_Element:}
  1632. ?
  1633. {  @Ruler_Element:}
  1634. _indent={nul2zero(RULER_INDENT)}
  1635. _lmargin={nul2zero(RULER_LEFTM)}
  1636. _pcolno={nul2zero(RULER_LEFTM)}
  1637. _rmargin={RULER_RIGHTM}
  1638. _tabs=\
  1639. {    if LEN(RULER_TABS) > 70 then}
  1640. ;
  1641. {      seperate(RULER_TABS);}
  1642.  
  1643. {    else}
  1644. "{RULER_TABS}"
  1645. {    endif}
  1646. {  @Fld_Element:}
  1647. //
  1648. {    x=Col_Positn;}
  1649. {    i=FLD_REPWIDTH;}
  1650. {    ni=0;}
  1651. {    pre_type=1;}
  1652. {    if i > 237 then}
  1653. {      foreach FLD_TEMPLATE fcursor in ecursor}
  1654. {        if ni then}
  1655. {          temp2=FLD_TEMPLATE;}
  1656. {        endif}
  1657. {        ++ni;}
  1658. {      next}
  1659. {    endif}
  1660. {    current_column=x+i;}
  1661. //
  1662. {    ++ecursor;}
  1663. {    nextrow=Row_Positn;}
  1664. {    if ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element then}
  1665. {      if current_column == Col_Positn && maxrow == Row_Positn then}
  1666. {        combine=1;}
  1667. {      else}
  1668. {        combine=0;}
  1669. {      endif}
  1670. {    endif}
  1671. {    --ecursor;}
  1672. //
  1673. {    k=0;}
  1674. {    x=0;}
  1675. {    priv_vars2="";}
  1676. {    if dBASE_III_PLUS == 2 && CHR(FLD_VALUE_TYPE) == "C" &&
  1677.      (FLD_FIELDTYPE == Tabl_data || FLD_FIELDTYPE == Calc_data) then}
  1678. {      priv_vars="TRIM(";}
  1679. {      x=1;}
  1680. {    else}
  1681. {      priv_vars="";}
  1682. {    endif}
  1683. {    d=0;
  1684.      if GROUP > 50 then
  1685.        case FLD_FIELDTYPE of
  1686.        Tabl_data: d=1;
  1687.        Calc_data: if GROUP < 97 && !FLD_HIDDEN && FLD_FIELDNAME && FLD_VALUE_TYPE == 67 then d=1; endif
  1688.        Pred_data: if GROUP < 97 && FLD_PREDEFINE == 2 then d=1; endif
  1689.        endcase
  1690.      endif
  1691.      if d then}
  1692. {      priv_vars="r_foot"+STR(current_group_footer_field);}
  1693. {      ++current_group_footer_field;}
  1694. {    else}
  1695. {    case FLD_FIELDTYPE of}
  1696. {    Tabl_data:}
  1697. // With ALIAS
  1698. //{      priv_vars=priv_vars+FLD_FILENAME+"->"+FLD_FIELDNAME;}
  1699. // Without ALIAS
  1700. {      priv_vars=priv_vars+FLD_FIELDNAME;}
  1701. {    Calc_data:}
  1702. {      if FLD_FIELDNAME then}
  1703. {        priv_vars=priv_vars+FLD_FIELDNAME;}
  1704. {      else}
  1705. {        foreach FLD_EXPRESSION fcursor in ecursor}
  1706. {          if k then}
  1707. {            priv_vars2=FLD_EXPRESSION;}
  1708. {          endif}
  1709. {          ++k;}
  1710. {        next}
  1711. {        if (UPPER(SUBSTR(LTRIM(FLD_EXPRESSION),1,5))) != "TRIM(" then}
  1712. {          priv_vars=priv_vars+FLD_EXPRESSION;}
  1713. {        else}
  1714. {          priv_vars=FLD_EXPRESSION;}
  1715. {          x=0;}
  1716. {        endif}
  1717. {      endif}
  1718. {    Pred_data:}
  1719. {      case FLD_PREDEFINE of}
  1720. {      0: // Date}
  1721. {        priv_vars="gd_date";}
  1722. {      1: // Time}
  1723. {        priv_vars="gc_time";}
  1724. {      2: // Recno}
  1725. {        priv_vars="RECNO()";}
  1726. {      3: // Pageno}
  1727. {        priv_vars="_pageno";}
  1728. {      endcase}
  1729. {    Summ_data:}
  1730. {      if !FLD_FIELDNAME then}
  1731. {        ++xsum;}
  1732. {        priv_vars="r_msum"+STR(xsum);}
  1733. //{        case FLD_OPERATION of}
  1734. //{        0: // Average}
  1735. //{          priv_vars=priv_vars+"[3]";}
  1736. //{        5: // standard deviation}
  1737. //{          priv_vars=priv_vars+"[5]";}
  1738. //{        6: // variance}
  1739. //{          priv_vars=priv_vars+"[5]";}
  1740. //{        endcase}
  1741. {      else}
  1742. {          priv_vars=FLD_FIELDNAME;}
  1743. //{        case FLD_OPERATION of}
  1744. //{        0: // Average}
  1745. //{          priv_vars=FLD_FIELDNAME+"[3]";}
  1746. //{        5: // standard deviation}
  1747. //{          priv_vars=FLD_FIELDNAME+"[5]";}
  1748. //{        6: // variance}
  1749. //{          priv_vars=FLD_FIELDNAME+"[5]";}
  1750. //{        otherwise: // count, min, max or sum}
  1751. //{          priv_vars=FLD_FIELDNAME;}
  1752. //{        endcase}
  1753. {      endif}
  1754. {    endcase}
  1755. {    endif}
  1756. {    if x then}
  1757. {      priv_vars2=priv_vars2+")";}
  1758. {    endif}
  1759. {    if !suppress_line &&
  1760.      (bandtype == Page_Header || bandtype == Page_Footer) then}
  1761. {      plainopt(ecursor);}
  1762. {    endif}
  1763. //
  1764. // For output of suppress repeated value memo fields
  1765. //
  1766. {    if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
  1767. lf_temp=\
  1768. {      goto memo_patch1}
  1769. {    endif}
  1770. {    memo_patch2:}
  1771. {    if isnew then}
  1772. {      isnew=0;}
  1773. ?? \
  1774. {    else}
  1775. {      if samerow then}
  1776. , \
  1777. {      else}
  1778. ?? \
  1779. {      endif}
  1780. {    endif}
  1781. {    if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
  1782. &lf_temp. \
  1783. {      goto memo_patch3}
  1784. {    endif}
  1785. {    memo_patch1:}
  1786. //
  1787. // Suppress repeated values?
  1788. //
  1789. {    if FLD_SUPPRESS then}
  1790. IIF(\
  1791. //
  1792. // Date field?
  1793. //
  1794. {      if CHR(FLD_VALUE_TYPE) == "D" then}
  1795. DTOS(r_msrv{xsrv}) \
  1796. {      else}
  1797. r_msrv{xsrv} \
  1798. {      endif}
  1799. <> \
  1800. //
  1801. // Date field?
  1802. //
  1803. {      if CHR(FLD_VALUE_TYPE) == "D" then}
  1804. DTOS({priv_vars}{priv_vars2})\
  1805. {      else}
  1806. //
  1807. // Memo field?
  1808. //
  1809. {        if CHR(FLD_VALUE_TYPE) == "M" then}
  1810. LEFT({priv_vars},254)\
  1811. {        else}
  1812. {priv_vars}{priv_vars2}
  1813. {        endif}
  1814. {      endif}
  1815. //
  1816. // Memo field?
  1817. //
  1818. {      if CHR(FLD_VALUE_TYPE) == "M" then}
  1819. ,[{priv_vars}],[""])
  1820. {      else}
  1821. ,{priv_vars}{priv_vars2},"") \
  1822. {      endif}
  1823. {    else}
  1824. {      priv_vars}{priv_vars2} \
  1825. {    endif}
  1826. {    if FLD_SUPPRESS && CHR(FLD_VALUE_TYPE) == "M" then}
  1827. {      goto memo_patch2}
  1828. {    endif}
  1829. {    memo_patch3:}
  1830. {    j=0;}
  1831. {    if FLD_PICFUN then}
  1832. {      temp=FLD_PICFUN;}
  1833. {      j=AT("V",temp) | AT("H",temp);}
  1834. {      if not j then}
  1835. FUNCTION "{FLD_PICFUN}" \
  1836. {      else}
  1837. {        if not AT("H",temp) then
  1838.            if j < LEN(FLD_PICFUN) then
  1839.              temp=SUBSTR(temp,1,j)+STR(i)+SUBSTR(temp,j+1);
  1840.            else
  1841.              temp=temp+STR(i);
  1842.            endif
  1843.          endif}
  1844. FUNCTION "{temp}" \
  1845. {      endif}
  1846. {    endif}
  1847. {    temp=FLD_TEMPLATE+temp2;}
  1848. {    if FLD_VALUE_TYPE == 67 then
  1849.        if FLD_LENGTH == FLD_REPWIDTH && temp == REPLICATE("X",FLD_LENGTH) then
  1850.          j=FLD_LENGTH;
  1851.        endif
  1852.      endif}
  1853. {    if not j then}
  1854. //
  1855. // test for invalid picture templates
  1856. //
  1857. {      if temp && (FLD_FIELDTYPE != Pred_data || FLD_PREDEFINE != 1) &&
  1858.        CHR(FLD_VALUE_TYPE) != "D" then}
  1859. {        if i > 70 then}
  1860. PICTURE ;
  1861. {          seperate(temp);}
  1862. {        else}
  1863. PICTURE "{FLD_TEMPLATE}" \
  1864. {        endif}
  1865. {      endif}
  1866. {    endif}
  1867. {  endcase}
  1868. //
  1869. // Style of output ie. BOLD, UNDERLINE and ITALICS.
  1870. //
  1871. {  if FLD_STYLE then}
  1872. STYLE "\
  1873. {    if Bold & FLD_STYLE then}
  1874. B\
  1875. {    endif}
  1876. {    if Italic & FLD_STYLE then}
  1877. I\
  1878. {    endif}
  1879. {    if Underline & FLD_STYLE then}
  1880. U\
  1881. {    endif}
  1882. {    if Superscript & FLD_STYLE then}
  1883. R\
  1884. {    endif}
  1885. {    if Subscript & FLD_STYLE then}
  1886. L\
  1887. {    endif}
  1888. {    if User_Font & FLD_STYLE then}
  1889. {      if  1 & FLD_STYLE then}1{endif}\
  1890. {      if  2 & FLD_STYLE then}2{endif}\
  1891. {      if  4 & FLD_STYLE then}3{endif}\
  1892. {      if  8 & FLD_STYLE then}4{endif}\
  1893. {      if 16 & FLD_STYLE then}5{endif}\
  1894. {    endif}
  1895. " \
  1896. {  endif}
  1897. //
  1898. // List type is TEXT or FIELD?
  1899. //
  1900. {  if (ELEMENT_TYPE == @Text_Element || ELEMENT_TYPE == @Fld_Element) then}
  1901. //
  1902. // not a word wrap band?
  1903. //
  1904. {    if !bandedit && first_combine then}
  1905. AT {Col_Positn}\
  1906. {      if maxrow == nextrow then}
  1907. ,
  1908. {      else}
  1909.  
  1910. {      endif}
  1911. {      isnew=1;}
  1912. {    else}
  1913. {      if maxrow == nextrow then}
  1914. ,
  1915. {        isnew=1;}
  1916. {      else}
  1917.  
  1918. {      endif}
  1919. {    endif}
  1920. //
  1921. // ***********************
  1922. //
  1923. {    if FLD_SUPPRESS && bsrv != xsrv then}
  1924. //
  1925. IF .NOT. (r_msrv{xsrv} = \
  1926. //
  1927. {      if !FLD_FIELDNAME then}
  1928. {        if FLD_FIELDTYPE == Calc_data then}
  1929. {          foreach FLD_EXPRESSION fcursor in ecursor}
  1930. {FLD_EXPRESSION}
  1931. {          next}
  1932. {        endif}
  1933. {        if FLD_FIELDTYPE == Summ_data then}
  1934. r_msum{xsum}\
  1935. {        endif}
  1936. {      else}
  1937. {        if CHR(FLD_VALUE_TYPE) == "M" then}
  1938. LEFT({FLD_FIELDNAME},254)\
  1939. {        else}
  1940. {FLD_FIELDNAME}
  1941. {        endif}
  1942. {      endif}
  1943. )
  1944. {      if !FLD_FIELDNAME then}
  1945.    r_msrv{xsrv}=\
  1946. {        if FLD_FIELDTYPE == Calc_data then}
  1947. {          foreach FLD_EXPRESSION fcursor in ecursor}
  1948. {FLD_EXPRESSION}
  1949. {          next}
  1950.  
  1951. {        endif}
  1952. {        if FLD_FIELDTYPE == Summ_data then}
  1953. r_msum{xsum}
  1954. {        endif}
  1955. {      else}
  1956.    r_msrv{xsrv}={FLD_FIELDNAME}
  1957. {      endif}
  1958. ENDIF
  1959. {    endif}
  1960. //
  1961. {    samerow=1;}
  1962. {    if first_combine && combine then}
  1963. {      first_combine=0;}
  1964. {    endif}
  1965. //
  1966. {    if !combine && !first_combine then}
  1967. {      first_combine=1;}
  1968. {    endif}
  1969. {  endif}
  1970. {  if bandtype == Page_Header || bandtype == Page_Footer then}
  1971. {    x=0;}
  1972. {    if previous_row < maxrow && nextrow > maxrow &&
  1973.      FLD_FIELDTYPE == Pred_data &&
  1974.      (!FLD_PREDEFINE || FLD_PREDEFINE == 3) then
  1975.        x=1;
  1976.      endif}
  1977. {    if x || (suppress_line && nextrow > maxrow) then}
  1978. {      if suppress_line && nextrow > maxrow then suppress_line=0; endif}
  1979. //
  1980. {      if optl_heading && nextrow > maxrow && bandtype != Page_Footer then}
  1981. ?
  1982. {        ++maxrow;}
  1983. {      endif}
  1984. {      lmarg(1);}
  1985. ENDIF
  1986. //
  1987. // Insert heading code if pageno exists
  1988. //
  1989. {      if !optl_heading && bandtype == Page_Header && bandrow+1 == Row_Positn
  1990.        && FLD_FIELDTYPE == Pred_data && FLD_PREDEFINE == 3 then}
  1991. *-- Print HEADING parameter ie. REPORT FORM <name> HEADING <expC>
  1992. IF .NOT. gl_plain .AND. gn_length > 0
  1993.    ?? " "
  1994.    ?? gc_heading FUNCTION "I;V"+;
  1995.    LTRIM(STR(_rmargin-_lmargin-(_pcolno*2+2)))
  1996. ENDIF
  1997. {        if nextrow > maxrow then}
  1998. IF .NOT. gl_plain
  1999.    ?
  2000. ENDIF
  2001. {          ++maxrow;}
  2002. {          isnew=1;}
  2003. {        endif}
  2004. {        optl_heading=1;}
  2005. {      endif}
  2006. //
  2007. {    endif}
  2008. {  endif}
  2009. {  noprint:}
  2010. {  x=0;}
  2011. {  previous_row=Row_Positn;}
  2012. {  ++ecursor;}
  2013. {enddo}
  2014. {if inner_loop then --ecursor; endif}
  2015. {next ecursor;}
  2016. //
  2017. // Output carriage returns for dBASE report to handle blank lines
  2018. //
  2019. {nextline3:}
  2020. {if maxrow < bandhgt then}
  2021. {  if isopen then}
  2022. ?
  2023. {  endif}
  2024. {  ++maxrow;}
  2025. {  goto nextline3;}
  2026. {endif}
  2027. {if bandtype == Report_Summary && is_rsumm_open then}
  2028. gl_fandl=.F.
  2029. ?
  2030. RETURN
  2031. * EOP: Rsumm
  2032. {endif}
  2033. {if bandtype == Page_Footer then}
  2034. {  finish_page_footer();}
  2035. {endif}
  2036.  
  2037. *-- Process page break when PLAIN option is used.
  2038. PROCEDURE Pgplain
  2039. PRIVATE _box
  2040. EJECT PAGE
  2041. {if number_of_reset_on_page || number_of_fld_suppress then}
  2042. IF gl_fandl
  2043.    DO Pageinit
  2044. ENDIF
  2045. {endif}
  2046. {if maxgrp > 3 && number_of_open_group_intros then}
  2047. IF gn_level = 0 .AND. gl_fandl
  2048.    gn_level=1
  2049.    DO Grphead
  2050. ENDIF
  2051. {endif}
  2052. RETURN
  2053. * EOP: Pgplain
  2054.  
  2055. *-- Reset dBASE environment prior to calling report
  2056. PROCEDURE Reset
  2057. SET SPACE &gc_space.
  2058. SET TALK &gc_talk.
  2059. ON ESCAPE
  2060. ON PAGE
  2061. RETURN
  2062. * EOP: Reset
  2063.  
  2064. {if !count then pause(report_empty + any_key); endif}
  2065. {Nogen:}
  2066. {return 0;}
  2067. //--------------------------------
  2068. // End of main template procedure
  2069. // User defined functions follow
  2070. //--------------------------------
  2071. {define nul2zero(number);
  2072.  if !number then
  2073.    number=0;
  2074.  endif
  2075.  return number;
  2076.  enddef
  2077. }
  2078. //
  2079. {
  2080.  define seperate(string);
  2081.  var x,y,length;
  2082.  x=1;
  2083.  length=LEN(string);
  2084.  moreleft:
  2085.  if x <= length then
  2086.    if x != 1 then}
  2087. + \
  2088. {  endif
  2089.    if x+70 <= length then y=70; else y=length-x+1; endif}
  2090. "{SUBSTR(string,x,y)}";
  2091. {  x=x+70;
  2092.    goto moreleft;
  2093.  endif
  2094.  return;
  2095.  enddef
  2096. }
  2097. {define plainopt(cursor);
  2098.  var temp; temp=0;
  2099.    if previous_row < maxrow && nextrow > maxrow &&
  2100.    cursor.FLD_FIELDTYPE == Pred_data &&
  2101.    (!cursor.FLD_PREDEFINE || cursor.FLD_PREDEFINE == 3) then
  2102.      temp=1;
  2103.    endif}
  2104. {  if temp || suppress_line then}
  2105. IF .NOT. gl_plain
  2106. {    LMARG(4);
  2107.    else
  2108.      if cursor.FLD_FIELDTYPE == Pred_data &&
  2109.      (!cursor.FLD_PREDEFINE || cursor.FLD_PREDEFINE == 3) then
  2110.        if !cursor.FLD_PREDEFINE then
  2111.          priv_vars="IIF(gl_plain,'',gd_date)";
  2112.        else
  2113.          priv_vars="IIF(gl_plain,'',_pageno)";
  2114.        endif
  2115.      endif
  2116.    endif
  2117.  return;
  2118.  enddef}
  2119. {define finish_page_footer();}
  2120. {  if suppress_line then
  2121.      suppress_line=0;}
  2122. //
  2123. {    LMARG(1);}
  2124. ENDIF
  2125. {  endif}
  2126. {  if isopen && bandhgt+1 then}
  2127. ENDIF
  2128. {  endif}
  2129. {  if demo_version then}
  2130. ? "{demo_string}" FUNCTION "IV"+LTRIM(STR(_rmargin-_lmargin))
  2131. {  endif}
  2132. EJECT PAGE
  2133. {  if number_of_begin_new_pages then}
  2134. gl_newpage=.T.
  2135. {  endif}
  2136. *-- is the page number greater than the ending page
  2137. IF _pageno > _pepage
  2138.    GOTO BOTTOM
  2139.    SKIP
  2140.    gn_level=0
  2141. ENDIF
  2142. {  if number_of_reset_on_page || number_of_fld_suppress then}
  2143. IF gl_fandl
  2144.    DO Pageinit
  2145. ENDIF
  2146. {  endif}
  2147. {  if is_page_header_open || (is_rintro_open && FRAME_PAGEHEADINGS)
  2148.    || number_of_open_group_intros then}
  2149. IF .NOT. gl_plain .AND. gl_fandl
  2150. {if bandspacing then}
  2151.    _pspacing={bandspacing}
  2152. {else}
  2153.    _pspacing=gn_pspace
  2154. {endif}
  2155.    DO Pghead
  2156. ENDIF
  2157. {  endif}
  2158. {  if maxgrp > 3 && number_of_open_group_intros then}
  2159. IF gn_level = 0 .AND. gl_fandl
  2160.    gn_level=1
  2161.    DO Grphead
  2162. ENDIF
  2163. {  endif}
  2164. gl_widow=.T.         && enable widow checking
  2165. RETURN
  2166. * EOP: Pgfoot
  2167. {return;
  2168.  enddef}
  2169. // EOP: REPORT.COD
  2170.