home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 15.22. The Vendor List example with "the works".
- Author: Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- //───── NOTE: must compile with the /N option!
-
- #define COND_ON sendCodes(chr(15))
- #define COND_OFF sendCodes(chr(18))
-
- function VendList()
- /*
- Print the Vendor Listing once again, this time using
- every trick we've learned in this chapter.
- */
-
- local prevHandler
- local sys_title, rpt_title, rpt_cond, rpt_id, col_head1, col_head2
- local page_len, page_width, top_mar, bot_mar, left_mar, right_mar
- local page_number := 0
-
- // Let user know what's happening, get confirmation to begin.
- @ 0,0 clear
- @ 8, 5 say "Vendor Listing"
- if .not. PrintReady(10,5)
- return nil
- endif
- @ 10, 5 say "Printing..."
-
- // Define the elements in the page heading.
- sys_title := "ACME Inventory Tracking"
- rpt_title := "Vendor Listing"
- rpt_cond := "(Active Vendors, Only)"
- rpt_id := "VLST-A"
- col_head1 := ;
- "Vendor Name Address YTD Total Contracted?"
- col_head2 := ;
- "-------------------- -------------------- --------- -----------"
-
- // Define the page dimensions.
- page_len := 66
- page_width := 80
- top_mar := 4
- bot_mar := 3
- left_mar := 8
- right_mar := 2
-
- // Post the printer error handler, save the previous.
- prevHandler:= errorBlock()
- errorBlock( {|error| PrintError(10, 5, error, prevHandler)} )
-
- // Get ready to begin report
- use vendor new
- goto top
- set device to printer
- setprc(0,0)
-
- // Start the reporting loop
- begin sequence
- do while .not. vendor->(eof())
-
- // Check if use wants to interrupt the report
- if CheckAbort(10, 5)
- break
- endif
-
- // Check to see if it's time to eject the page,
- // and if so, print page and column headings.
- if PageEject(page_len, top_mar, bot_mar)
- page_number++
- PageHead(sys_title, rpt_title, rpt_id, ;
- page_width, left_mar, right_mar, page_number)
- NextRow(2, left_mar, col_head1)
- NextRow(1, left_mar, col_head2)
- endif
-
- // Print a line in the main body
- NextRow(1, left_mar, Vendor->Name)
- SameRow(2, Vendor->Address)
- SameRow(2, Vendor->YTD, "$9,999.99")
- SameRow(6, if(Vendor->Contract, "Yes", "No"))
- skip alias vendor
- enddo
-
- // Print the last message in condensed type.
- COND_ON
- NextRow(2, left_mar, "*** End of Report ***")
- COND_OFF
- eject
- end sequence
-
- // Restore previous error handler
- errorBlock(prevHandler)
-
- // Close 'er down, we're done.
- set device to screen
- @ 10, 0 clear
- @ 10, 5 say "...finished."
- close databases
-
- return nil
-
- // end of file CHP1522.PRG
-