home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP15.EXE / CHP1522.PRG < prev   
Encoding:
Text File  |  1991-04-30  |  2.9 KB  |  109 lines

  1. /*
  2.    Listing 15.22. The Vendor List example with "the works".
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. #define COND_ON   sendCodes(chr(15))
  14. #define COND_OFF  sendCodes(chr(18))
  15.  
  16. function VendList()
  17. /*
  18.    Print the Vendor Listing once again, this time using
  19.    every trick we've learned in this chapter.
  20. */
  21.  
  22. local prevHandler
  23. local sys_title, rpt_title, rpt_cond, rpt_id, col_head1, col_head2
  24. local page_len, page_width, top_mar, bot_mar, left_mar, right_mar
  25. local page_number := 0
  26.  
  27.   //  Let user know what's happening, get confirmation to begin.
  28.   @ 0,0 clear
  29.   @ 8, 5 say "Vendor Listing"
  30.   if .not. PrintReady(10,5)
  31.     return nil
  32.   endif
  33.   @ 10, 5 say "Printing..."
  34.  
  35.   //  Define the elements in the page heading.
  36.   sys_title := "ACME Inventory Tracking"
  37.   rpt_title := "Vendor Listing"
  38.   rpt_cond  := "(Active Vendors, Only)"
  39.   rpt_id    := "VLST-A"
  40.   col_head1 := ;
  41.     "Vendor Name           Address              YTD Total  Contracted?"
  42.   col_head2 := ;
  43.     "--------------------  -------------------- ---------  -----------"
  44.  
  45.   //  Define the page dimensions.
  46.   page_len   := 66
  47.   page_width := 80
  48.   top_mar    := 4
  49.   bot_mar    := 3
  50.   left_mar   := 8
  51.   right_mar  := 2
  52.  
  53.   //  Post the printer error handler, save the previous.
  54.   prevHandler:= errorBlock()
  55.   errorBlock( {|error| PrintError(10, 5, error, prevHandler)} )
  56.  
  57.   //  Get ready to begin report
  58.   use vendor new
  59.   goto top
  60.   set device to printer
  61.   setprc(0,0)
  62.  
  63.   //  Start the reporting loop
  64.   begin sequence
  65.     do while .not. vendor->(eof())
  66.  
  67.       //  Check if use wants to interrupt the report
  68.       if CheckAbort(10, 5)
  69.         break
  70.       endif
  71.  
  72.       //  Check to see if it's time to eject the page,
  73.       //  and if so, print page and column headings.
  74.       if PageEject(page_len, top_mar, bot_mar)
  75.          page_number++
  76.          PageHead(sys_title, rpt_title, rpt_id, ;
  77.                   page_width, left_mar, right_mar, page_number)
  78.          NextRow(2, left_mar, col_head1)
  79.          NextRow(1, left_mar, col_head2)
  80.       endif
  81.  
  82.       //  Print a line in the main body
  83.       NextRow(1, left_mar, Vendor->Name)
  84.       SameRow(2, Vendor->Address)
  85.       SameRow(2, Vendor->YTD, "$9,999.99")
  86.       SameRow(6, if(Vendor->Contract, "Yes", "No"))
  87.       skip alias vendor
  88.     enddo
  89.  
  90.     //  Print the last message in condensed type.
  91.     COND_ON
  92.     NextRow(2, left_mar, "*** End of Report ***")
  93.     COND_OFF
  94.     eject
  95.   end sequence
  96.  
  97.   //  Restore previous error handler
  98.   errorBlock(prevHandler)
  99.  
  100.   //  Close 'er down, we're done.
  101.   set device to screen
  102.   @ 10, 0 clear
  103.   @ 10, 5 say "...finished."
  104.   close databases
  105.  
  106. return nil
  107.  
  108. // end of file CHP1522.PRG
  109.