1 / 27

Moving Data, Printing Information, and Formatting Output

Moving Data, Printing Information, and Formatting Output. Chapter 6. MOVE Statement. MOVE identifier-1 TO identifier-2 Copies contents of identifier-1 To identifier-2 identifier-1 is sending field identifier-2 is receiving field. FORMAT 1:. Moving Figurative Constants.

doris
Download Presentation

Moving Data, Printing Information, and Formatting Output

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Moving Data, Printing Information, and Formatting Output Chapter 6

  2. MOVE Statement • MOVE identifier-1 TO identifier-2 • Copies contents of identifier-1 To identifier-2 • identifier-1 is sending field • identifier-2 is receiving field FORMAT 1:

  3. Moving Figurative Constants • ZEROS may be moved to numeric or alphanumeric field • SPACES moved only to alphanumeric field

  4. Rules for Nonnumeric MOVE • Characters moved from left to right • If receiving field longer, low-order (rightmost) positions replaced with spaces • If receiving field shorter, low-order characters in sending field truncated

  5. Group Moves • When receiving field is group item, alphanumeric MOVE rules followed • If subfields are numeric, invalid data may be stored in subfields

  6. Plus or Minus Signs • PIC clause with 9’s is unsigned field • Value assumed to be positive • Use S with 9’s in PIC clause of sending field to define signed field • Use PIC of S9(3) to store -425 • Report-item field must include + or - editing symbol to print or display a sign

  7. Displaying Minus or Plus Sign Assume a PICTURE of S9(3) for WS-AmtOut-AmtWS-AmtPICTUREContents 007- -ZZZ -bb7 218+ ZZZ- 218b 082+ +ZZ9 +b82 030- $ZZZ+ $b30- Examples:

  8. Spaces, Zeros, or Slashes • B (space or blank), 0 (zero) or / (slash) may be inserted in report-item PIC as separator • Used to edit either nonnumeric or numeric fields

  9. Spaces, Zeros, or Slashes Assume PIC 9(3) for WS-Amt PIC X(3) for WS-Name Report-Item ContentsPICTUREContentsWS-Amt 528 99BB9 52bb8WS-Amt 218 999,000 218,000WS-Name RAY XBXBX RbAbY WS-Name JAN X/X/X J/A/N Examples:

  10. Editing with Floating Strings • Used to place $, + or - directly preceding first significant digit • For example, 000516 becomes $5.16 instead of $ 5.16 • In edit string, replace all Z’s with floating character ($, + or -) • Suppresses leading zeros, commas

  11. Editing with Floating Strings Assume a PICTURE of S9(4)V99 for WS-AmtOut-AmtWS-AmtPICTUREContents 0002^29- $$,$$$.99 bbbb$2.29- 0036^62+ ++,+++.99 bbb+36.62 0007^05- ---99.99 bb-07.05 Examples

  12. Illegal Move Statements • MOVE alphanumeric-field TO numeric-field • MOVE alphanumeric-field TO numeric-edited-field • MOVE numeric-field-with-decimal-positions TO alphanumeric-field • MOVE group-field TO numeric-field • MOVE group-field TO numeric-edited-field

  13. File Access • “Read a File…” • “…Write a Record!”

  14. File Access • READ the input file and MOVE the entire record to an area in working storage. • READ filename INTO ws-area • Format the output line in WS, move the ws-area to the output record, WRITE the record. • WRITE record FROM ws-area

  15. WRITE … FROM Statement • To transfer data from storage to print area and then print • Replaces MOVE and WRITEWrite Print-Rec From Heading-1 instead ofMove Heading-1 to Print-Rec Write Print-Rec

  16. ADVANCING Option • Single spacing for WRITE is default • Use AFTER or BEFORE ADVANCING to obtain any number of blank lines between each print line

  17. WRITE … AFTER ADVANCING • Write Print-Rec From Heading-Line-1 After Advancing 2 Lines • Causes paper to advance two lines • Heading-Line-1 printed on second line • Creates double spacing - one blank line followed by printed line

  18. WRITE … BEFORE ADVANCING • Write Print-Rec From Heading-Line-1 Before Advancing 2 Lines • Heading-Line-1 printed first, then spaces two lines • Results in overprinting if first line already contains printed output • As a rule, use either BEFORE or AFTER in program but not both

  19. PAGE option • Word PAGE after ADVANCING causes paper to advance to next page • To advance paper to top of new page and print a heading, code Write Print-Rec From Heading-Line-1 After Advancing Page

  20. End-of-Page Control • When page is full, need to advance to next page and print headings again • Define WORKING-STORAGE field for line counter • Initialize line counter to zero and increment it each time a line is printed • When line counter equals or exceeds line limit for page, advance to next page

  21. Printing Page Numbers • Define WORKING-STORAGE field for page number • Initialize and then increment page number each time new page begins • Move page number to report-item in heading line before printing it at top of a new page

  22. Accessing Date of Run • To get current date in program, access reserved word DATE • Stores date as six-digit field, two digits each for year, month and day • January 25, 2004 stored as 040125

  23. Accessing Date of Run ACCEPT identifier-1 FROMDATE FORMAT:

  24. Accessing Date of Run Accept WS-Date From Date • Where WS-Date defined as: 01 WS-Date. 05 Run-Year PIC 99. 05 Run-Month PIC 99. 05 Run-Day PIC 99. EXAMPLE:

  25. Printing Date of Run • WS-Date fields typically reformatted for printing • Moved to report-item fields listed in month, day, year order with slashes between them

  26. Report Headings • Print a primary heading at the top of the first page • Print page and column headings at the top of the first page and at the top of each subsequent page • Print a footer at the bottom of each page (i.e., page number) • Optional: Print a summary at the end of the report

  27. Report Layouts • The 132-position width is somewhat standard because most mainframe high-speed printers can print 132-position lines. • This IS NOT the case with our VAX system. • We are limited to 80-character print lines.

More Related