Chapter 7: Control Breaks Programming Logic and Design, Third Edition Comprehensive.

Slides:



Advertisements
Similar presentations
MASTER QUOTE OVERVIEW.
Advertisements

Programming with Microsoft Visual Basic th Edition
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module J (Office 2010 Version) Implementing.
Chapter 2: Modularization
Chapter 9: Advanced Array Manipulation
System Design System Design - Mr. Ahmad Al-Ghoul System Analysis and Design.
Programming Logic and Design Fourth Edition, Introductory
Programming Logic and Design, Second Edition, Comprehensive
Microsoft Access 2013 ®® Tutorial 7 Creating Custom Reports.
INSERT BOOK COVER 1Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Microsoft Access 2010 by Robert Grauer, Keith Mast,
Programming Logic and Design, Third Edition Comprehensive
Programming Logic and Design Fourth Edition, Introductory
Writing a Complete Program
Modules, Hierarchy Charts, and Documentation
Understanding the Mainline Logical Flow Through a Program (continued)
Programming Logic and Design Fourth Edition, Comprehensive
Chapter 13: Object-Oriented Programming
General Algorithms for Common Business Problems
Chapter 1 Program Design
Programming Logic and Design, Third Edition Comprehensive
- Meeting 4 – Writing a Complete Program
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout.
Chapter 07 Control Breaks.
10- 1 Chapter 10. To familiarize you with  Main types of computer-generated reports  Techniques used for efficient printing of group reports and control.
Programming Logic and Design Seventh Edition
10-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Database Applications – Microsoft Access Lesson 9 Designing Special Queries Updated 4/11.
Database Applications – Microsoft Access Lesson 9 Designing Special Queries.
Simple Program Design Third Edition A Step-by-Step Approach
Programming Logic and Design, Second Edition, Comprehensive
October 2003Bent Thomsen - FIT 3-21 IT – som værktøj Bent Thomsen Institut for Datalogi Aalborg Universitet.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
1 Data List Spreadsheets or simple databases - a different use of Spreadsheets Bent Thomsen.
Programming Logic and Design, Second Edition, Comprehensive
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
Database Systems Microsoft Access Practical #2 Making Forms and Reports Nos 215.
File Handling and Control Break Logic. Objectives In this chapter, you will learn about: Computer files Writing a program that reads from and/or writes.
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
1 Reports. 2 Objectives  Use concatenation in a query  Change column headings and formats  Add a title to a report  Group data in a report  Include.
General Algorithms for Common Business Problems Simple Program Design Third Edition A Step-by-Step Approach 10.
Database Applications – Microsoft Access Lesson 7 Designing Custom Reports Updated 11/13 27 Slides in Presentation.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
Dawn Squires.  When viewing a table in Access, all of the records are visible simultaneously.  Sometimes that can be confusing.  To view only one record.
Gold – Crystal Reports Introductory Course Cortex User Group Meeting New Orleans – 2011.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Control Break Processing
COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Chapter 11: Sequential File Merging, Matching, and Updating Programming Logic and Design, Third Edition Comprehensive.
11 Chapter 111 Sequential File Merging, Matching, and Updating Programming Logic and Design, Second Edition, Comprehensive 11.
Chapter 9 General algorithms for common business problems.
ACCESS REPORT GENERATOR. IT Fundamentals2 Reports Overview Reports are an important part of any computer business application. Features that are important.
Chapter 4 Crystal Report Presenter: PEN PHIROM (MscIT) Phone:
Microsoft® Access Generate reports quickly 1 Modify controls in layout view 2 Work with report sections 3 Work with controls in a report 4 Use Format.
Lesson 16 Enhancing Documents
Creating Custom Reports, Macros, and Switchboards
Lesson 16 Enhancing Documents
Database Applications – Microsoft Access
Programming Logic and Design Eighth Edition
Programming Logic and Design Fourth Edition, Comprehensive
Exploring Microsoft® Access® 2016 Series Editor Mary Anne Poatsy
Structured COBOL Programming
Designing and Writing Control-Break Programs
Word offers a number of features to help you streamline the formatting of documents. In this chapter, you will learn how to use predesigned building blocks.
CHAPTER 17 The Report Writer Module
Writing a Complete Program
Chapter 18 Finalizing a Database.
Bent Thomsen Institut for Datalogi Aalborg Universitet
Chapter 4: Writing and Designing a Complete Program
Presentation transcript:

Chapter 7: Control Breaks Programming Logic and Design, Third Edition Comprehensive

2 Objectives After studying Chapter 7, you should be able to: Understand control break logic Perform single-level control breaks Use control data within a heading in a control break module

Programming Logic and Design, Third Edition Comprehensive3 Objectives ( continued ) Use control data within a footer in a control break module Perform control breaks with totals Perform multiple-level control breaks Perform page breaks

Programming Logic and Design, Third Edition Comprehensive4 Understanding Control Break Logic A control break is a temporary detour in the logic of a program A control break program is when a change in the value of a variable initiates special actions or causes special or unusual processing to occur If you have ever read a report that lists items in groups, with each group followed by a subtotal, then you have read a type of control break report

Programming Logic and Design, Third Edition Comprehensive5 Understanding Control Break Logic ( continued ) Some other examples of control break reports produced by control break programs include: –All employees listed in order by department number, with a new page started for each department –All company clients listed in order by state of residence, with a count of clients after each state’s client list

Programming Logic and Design, Third Edition Comprehensive6 Understanding Control Break Logic ( continued ) Each of the previously mentioned reports share two traits: –The records used in each report are listed in order by a specific variable: department, state, category, or date –When that variable changes, the program takes special action: starts a new page, prints a count or total, or switches ink color Programs that sort records take records that are not in order and rearrange them so that they are in order

Programming Logic and Design, Third Edition Comprehensive7 Performing a Single-Level Control Break to Start a New Page Suppose you want to print a list of employees, advancing to a new page for different departments Figure 7-1 shows the input file description –the employee department is a two-digit numeric field – the file has been presorted so that the records will arrive in a program in employee-department- number order Figure 7-2 shows the desired output—a simple list of employee names

Programming Logic and Design, Third Edition Comprehensive8 Performing a Single-Level Control Break to Start a New Page ( continued )

Programming Logic and Design, Third Edition Comprehensive9 Performing a Single-Level Control Break to Start a New Page ( continued ) A single-level control break: a break in the logic of the program (pausing or detouring to print new headings) based on the value of a single variable (the department number) To “remember” the old department number, create a special variable, called a control break field, to hold the previous department number –Every time you read in a record and print it, you also can save the crucial part of the record that will signal the change or control the program break

Programming Logic and Design, Third Edition Comprehensive10 Using Control Data Within a Heading in a Control Break Module

Programming Logic and Design, Third Edition Comprehensive11 Using Control Data Within a Heading in a Control Break Module ( continued ) Figure 7-8 shows variable data in the heading—a different department number prints at the top of each page of employees To create this kind of program, you must make two changes in the existing program

Programming Logic and Design, Third Edition Comprehensive12 Using Control Data Within a Heading in a Control Break Module ( continued ) First, you modify the newPage() module, as shown in Figure 7-9 Additionally, you must modify the housekeeping() module to ensure that the first heading on the report prints correctly As Figure 7-9 shows, you must modify the housekeeping() module from Figure 7-4 so that you read the first empRec prior to printing the headings

Programming Logic and Design, Third Edition Comprehensive13 Modified newPage() And housekeeping() Modules for Employees by Department Report

Programming Logic and Design, Third Edition Comprehensive14 Using Control Data Within a Footer in a Control Break Module ( continued ) A message that prints at the end of a page or other section of a report is called a footer Headings usually require information about the next record; footers usually require information about the previous record

Programming Logic and Design, Third Edition Comprehensive15 Using Control Data Within a Footer in a Control Break Module ( continued )

Programming Logic and Design, Third Edition Comprehensive16 Performing Control Breaks With Totals Suppose you run a bookstore, and one of the files you maintain is called BOOKFILE, which has one record for every book title that you carry Each record has fields such as bookTitle, bookAuthor, bookCategory (fiction, reference, self-help, and so on), bookPublisher, and bookPrice, as shown in the file description in Figure 7-12

Programming Logic and Design, Third Edition Comprehensive17 Performing Control Breaks With Totals ( continued ) Suppose you want to print out a list of all the books that your store carries, with a total number of books at the bottom of the list, as shown in Figure 7-13 You can use the logic shown in Figure 7-14

Programming Logic and Design, Third Edition Comprehensive18 Performing Control Breaks With Totals ( continued )

Programming Logic and Design, Third Edition Comprehensive19 Performing Control Breaks With Totals ( continued ) As you will see from the pseudocode in Figure 7- 14, the bookListLoop() module performs three major tasks: –Prints a book title –Adds 1 to the grandTotal –Reads in the next book record

Programming Logic and Design, Third Edition Comprehensive20 Flowchart and Pseudocode for Bookstore Program

Programming Logic and Design, Third Edition Comprehensive21 Performing Multiple-Level Control Breaks Let’s say your bookstore from the last example is so successful that you have a chain of them across the country Every time a sale is made, you create a record with the fields bookTitle, bookPrice, bookCity, and bookState You want a report that prints a summary of books sold in each city and each state, similar to the one shown in Figure 7-16

Programming Logic and Design, Third Edition Comprehensive22 Performing Multiple-Level Control Breaks ( continued ) This is a summary report and does not include any informatio n about individual records, only group totals

Programming Logic and Design, Third Edition Comprehensive23 Performing Multiple-Level Control Breaks ( continued ) This program contains multiple-level control breaks –the normal flow of control (reading and counting book sales) breaks away to print totals in response to more than just one change in condition

Programming Logic and Design, Third Edition Comprehensive24 Performing Multiple-Level Control Breaks ( continued ) A control break occurs in response to either (or both) of two conditions: –when the contents of the bookCity variable changes –when the contents of the bookState variable changes The input file you use to create a multiple-level control break report must be presorted, just like the files used to create a single-level control break

Programming Logic and Design, Third Edition Comprehensive25 Performing Page Breaks Many business programs use a form of control break logic to start a new page when a printed page fills up with output The logic involves: –counting the lines printed –pausing to print headings when the counter reaches some predetermined value – moving on This is another example of providing a break in the usual flow of control

Programming Logic and Design, Third Edition Comprehensive26 Performing Page Breaks ( continued ) Let’s say you have a file called CUSTOMERFILE containing 1,000 customers, with two charcter fields that you have decided to call custLast and custFirst You want to print a list of these customers, 60 lines to a page, in the format shown in Figure 7-23 below

Programming Logic and Design, Third Edition Comprehensive27 Performing Page Breaks ( continued ) The mainline logic of the program is familiar The only new feature is a variable called a line counter You will use a line-counter variable to keep track of the number of printed lines, so that you can break to a new page after printing 60 lines, as shown in Figure 7-24

Programming Logic and Design, Third Edition Comprehensive28 Mainline Logic of Customer Report Program

Programming Logic and Design, Third Edition Comprehensive29 Summary A control break is a temporary detour in the logic of a program; –programmers refer to a program as a control break program when a change in the variable initiates special actions or causes special or unusual processing to occur You use a control break field to hold data from a previous record

Programming Logic and Design, Third Edition Comprehensive30 Summary ( continued ) A control break report: –contains and prints totals for the previous group –rolls up the current-level totals to the next higher level –resets the current level’s totals to zero –performs any other needed control break processing –updates the control break field

Programming Logic and Design, Third Edition Comprehensive31 Summary ( continued ) In a program containing a multiple-level control break, –the normal flow of control breaks away for special processing in response to a change in more than one field To perform page breaks, you –count the lines printed and – pause to print headings when the counter reaches some predetermined value