Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.

Slides:



Advertisements
Similar presentations
16-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)
Advertisements

2-1 Chapter 2.  Coding Requirements of IDENTIFICATION DIVISION  Sections of ENVIRONMENT DIVISION  Assigning Files to Devices in ENVIRONMENT DIVISION.
3-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emertius)
7-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)
Chapter 2 Data Types, Declarations, and Displays
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Chapter 2 Basic SQL SELECT Statements
COBOL Basics 1. COBOL coding rules  Almost all COBOL compilers treat a line of COBOL code as if it contained two distinct areas. These are known as;
3-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emertius)
Modifications to program Addda.cbl Please use speaker notes for additional information!
History COBOL (Common Business Oriented Language) was one of the earliest high-level programming languages. COBOL was first proposed in 1959 by the Conference.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Agenda  Commenting  Inputting Data from Keyboard (scanf)  Arithmetic Operators  ( ) * / + - %  Order of Operations  Mixing Different Numeric Data.
Pascal Programming Strings, Arithmetic operators and output formatting National Certificate – Unit 4 Carl Smith.
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
A First Book of ANSI C Fourth Edition Chapter 3 Processing and Interactive Input.
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Input, Output, and Processing
Agenda Reporting Work on Assignment 4! Printing on power systems.
7-1 Structured COBOL Programming Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout John.
Lecture 31 Numeric Edited Alphabetic (A) AlphaNumeric (X) Numeric (9, V, S) Numeric Edited (9, Z, comma, decimal point, minus sign) –Z = zero suppressed.
The DATA DIVISION Chapter 3. COBOL Data Organization Field - group of characters forming a meaningful unit or basic fact –Characters in a name or digits.
3-1 Chapter 3. To familiarize you with  Ways in which data is organized in COBOL  Rules for forming data-names  Defining input and output files in.
3-1 The DATA DIVISION Chapter Chapter Objectives To familiarize you with Systems design considerations Ways in which data is organized Rules for.
Printing on power systems Program/ Command Data Report Layout (Printer File) Job Output Queue *FILE Spooled File.
COBOL Basics 2. H E N N E S S Y R M L M F Group Items/Records StudentDetails WORKING-STORAGE SECTION. 01StudentDetailsPIC X(26).
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
To familiarize you with  Options of MOVE statement  Rules for moving fields and literals  Printing edit symbols  Designing and printing reports 1.
Statement Syntax1 THE SELECT STATEMENT Purpose: designates a file and points to its physical location Syntax Definition : SELECT file-name-1 ASSIGN TO.
CPSC3111/CISM3111 COBOL Structured COBOL Programming Text: murach’s structured COBOL Authors: Murach, Prince, Menendez.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Lecture 41 Arithmetic Clauses The ROUNDED clause –Place ROUNDED after the variable that holds the result ADD A TO B ROUNDED. ADD A TO B GIVING C ROUNDED.
Arithmetic and Edited Pictures. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal.
Module 6 Arithmetic. Arithmetic Verb Template  Most COBOL arithmetic verbs conform to the template above. For example; ADD Takings TO CashTotal. ADD.
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Any Questions!. Test Coming Up! Agenda Printing with Externally Described Printer Files Arrays.
7-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)
1 Chapter 5 – The Procedure Division File handling statements –OPEN statement Initiates processing for a file Input Output Each file opened must have been.
2-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)
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
1.  Introduction  The Benefits of the Report Writer Module ◦ For Detail and Summary Printing ◦ For Control Break Processing ◦ For Printing Headings.
Lecture 101 String Processing Operations on numeric edited fields i.e., view the PIC as a string of characters –Reference modification read/write substrings.
Lecture 21 ENVIRONMENT DIVISION  defines files external to the program and devices.  contains two sections: 1.CONFIGURATION SECTION.  identifies computers.
Any Questions? Week 1 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
This is It! It’s been a pleasure! Final Exam – format True / false 5 Multiple choice 5 Short answers10 Data manipulation10 SQL 3 Array’s12 File processing25.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
Any Questions! 2 Agenda Moving data Arithmetic Verbs Compute statement.
Week 2/3 - 2nd Lecture Intro to COBOL Programming Defining Files and Processing Data.
16- 1 Chapter 16.  To familiarize you with  COPY statement for copying parts of a program stored in a library  CALL statement for executing called.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
ECE 1304 Introduction to Electrical and Computer Engineering
String Methods Programming Guides.
Variables, Expressions, and IO
Programming in COBOL.
Any Questions?.
Chapter 3 The DATA DIVISION.
Writing Basic SQL SELECT Statements
Agenda Collating sequence / Sorting data
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
THE COMPUTE STATEMENT Purpose: performs mathematical calculations
Just Basic Lessons 7&8 Mr. Kalmes.
Any Questions?.
Decision Making Using the IF and EVALUATE Statements
Programming in COBOL.
Presentation transcript:

Any Questions?

Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect

Level 77 Used to define stand alone elementary items. No limit to the “number of” used in a program. Exclusively used in the WORKING-STORAGE SECTION ie. 77 ws-counter pic s9(5). 77 ws-alpha-work pix x(30).

Initialize Verb 01 Group-Item Num1 PIC 9(4) VALUE Num2 PIC 9(4) VALUE Alpha1 PIC X(10) VALUE ‘COBOL’. 05 Alpha2PIC X(20) VALUE ‘FUN’. INITIALIZE NUM1. INITIALIZE ALPHA1 NUM2. What happens?

Initialize Verb 01 Group-Item Num1 PIC 9(4) VALUE Num2 PIC 9(4) VALUE Alpha1 PIC X(10) VALUE ‘COBOL’. 05 Alpha2PIC X(20) VALUE ‘FUN’. INITIALIZE Group-Item-1. What happens?

Initialize Verb INITIALIZE variable1 variable2 variable3 … ALPHABETIC REPLACING ALPHANUMERIC NUMERIC ALPHANUMERIC-EDITED NUMERIC-EDITED BY Variable4 literal-1

Initialize Verb 01 Group-Item Num1 PIC 9(4) VALUE Num2 PIC 9(4) VALUE Alpha1 PIC X(10) VALUE ‘COBOL’. 05 Alpha2PIC X(20) VALUE ‘FUN’. INITIALIZE Group-Item-1 REPLACING ALPHANUMERICS BY ‘X’ NUMERIC BY 9 What happens?

Initialize Verb 01 Group-Item Num1 PIC 9(4) VALUE Num2 PIC 9(4) VALUE Alpha1 PIC X(10) VALUE ‘COBOL’. 05 Alpha2PIC X(20) VALUE ‘FUN’. INITIALIZE Group-Item-1 REPLACING NUMERICS BY 100. What happens?

Display & Accept Fast Interactive Screens Use of message queue / command line

Display DISPLAY variable1/literal1 variable2/literal2… AT LINE 99 COLUMN 99. Examples: DISPLAY STUDENT-RECORD. DISPLAY ‘Amount: ’ TRANS-AMOUNT. DISPLAY ‘Amount: ’ TRANS-AMOUNT AT LINE 8 COLUMN 10.

ACCEPT ACCEPT variable1 AT LINE 99 COLUMN 99. Examples: DISPLAY ‘Press Enter to Continue’. ACCEPT ENTER-VARIABLE.

Arithmetic Verbs Add, Subtract, Multiply, Divide And Compute

Add Verb Three Formats: ADD variable/constant TO variable ADD variable/constant, variable/constant, … GIVING variable ADD variable/constant TO variable/constant GIVING variable

ADD Verb A = 100B = 50 C = 300 ADD A to B A = B = C = ADD A to B GIVING C A = B = C = What would happen if C was PIC 9(2)?

SUBTRACT Verb Two Formats: SUBTRACT Variable/Constant Variable/Constant... FROM Variable SUBTRACT Variable/Constant Variable/Constant … FROM Variable GIVING Variable

SUBTRACT Statement A = 100 B = 50C = 150D = 200 SUBTRACT A B FROM C A = B = C = D = SUBTRACT A B FROM C GIVING D A = B = C = D =

MULTIPLY Statement More restrictive Two Formats MULTIPLY variable/constant BY variable MULTIPLY variable/constant BY variable/constant GIVING variable

MULTIPLY Statement A = 50B = 100C = 20 MULTIPLY A BY B A = B = C = MULTIPLY A BY B GIVING C A = B = C =

DIVIDE Statement More restrictive - Three Formats - Decimal alignment DIVIDE variable/constant INTO variable DIVIDE variable/constant INTO variable/constant GIVING variable DIVIDE variable/constant BY variable/constant GIVING variable

DIVIDE Statement A = 100B = 50C = 25 DIVIDE A INTO B A =B = C = DIVIDE A BY B GIVING C A = B = C =

REMAINDER Clause Two formats: DIVIDE variable/constant INTO variable/constant GIVING variable REMAINDER variable DIVIDE variable/constant BY variable/constant GIVING variable REMAINDER variable DECIMAL ALIGNMENT!

REMAINDER Clause A = 100 B = 150C = 20D = 10 DIVIDE A INTO B GIVING C REMAINDER D. A = B = C = D =

Clauses that work with all arithmetic statements. ROUNDED ON SIZE ERROR

Rounding Add the ROUNDED option to the math statement directly following the resulting field Eg. DIVIDE A INTO B GIVING C ROUNDED.

ON SIZE ERROR option What to do if the resulting value from the Mathematical Expression is too big for the result variable leading or trailing the decimal position. Used to Resolve Divide by Zero errors. ADD A B GIVING C ON SIZE ERROR PERFORM ERROR-HANDLING-ROUTINE.

Compute Statement Combines all of the math verbs plus exponentiation

Compute Statement Symbols

Order of Operations Operations in brackets ( ) are performed first ** (exponentiation) * or / (from left to right) + or - (from left to right)

Compute Statement A = 10B = 2C = 60 D is PIC 9(4) COMPUTE D ROUNDED = A ** B / ( A - B) + C. What is the value of D?

73

STRING Statement Used to Concatenate character strings together.

STRING Statement STRING Variable/Constant DELIMITED BY {Variable/Constant/SIZE) INTO variable END-STRING

STRING Statement Rules DELIMITED BY required Receiving field must be an elementary data (not a group item) element with no editing symbols All literals must be alphanumeric String moves data from left-right but doesnot pad with blanks

STRING Statement STRING first-name DELIMITED BY ‘ ‘ last-name DELIMITED BY ‘ ‘ INTO full-name END-STRING first-namelast-namefull-name ‘Cindy ‘‘Laurin’

STRING Statement STRING first-name DELIMITED BY ‘ ‘ ‘ ‘ DELIMITED BY SIZE last-name DELIMITED BY ‘ ‘ INTO full-name END-STRING first-namelast-namefull-name ‘Cindy ‘‘Laurin ‘

STRING Statement MOVE ‘XXXXXXXXXXXXXXXXXXXXXXXX’ TO full-name. STRING first-name DELIMITED BY ‘ ‘ ‘ ‘ DELIMITED BY SIZE last-name DELIMITED BY ‘ ‘ INTO full-name END-STRING first-namelast-namefull-name ‘Cindy ‘‘Laurin ‘

We can concatenate strings together using the String Verb. Wouldn’t it be nice if we could parse a string into other strings?

UNSTRING Verb!! UNSTRING Variable DELIMITED BY Variable/Constant/SIZE INTO variable1 variable2 variable3 END-UNSTRING

UNSTRING 01 Name-In-Pieces. 05 Last-NamePIC X(16). 05 First-Name PIC X(10). 05 Middle-InitialPIC X. 01 Entire-NamePIC X(31) VALUE ‘Cindy M Laurin’. UNSTRING Entire-Name DELIMITED BY ‘ ‘ INTO First-Name Middle-Initial Last-Name.

UNSTRING 01 Name-In-Pieces. 05 Last-NamePIC X(16). 05 First-Name PIC X(10). 05 Middle-InitialPIC X. 01 Entire-NamePIC X(31) VALUE ‘Eddie Laurin’. UNSTRING Entire-Name DELIMITED BY ‘ ‘ INTO First-Name Middle-Initial Last-Name.

UNSTRING 01 Name-In-Pieces. 05 Last-NamePIC X(16). 05 First-Name PIC X(10). 05 Middle-InitialPIC X. 01 Entire-NamePIC X(31) VALUE ‘Cindy M Laurin-Moogk’ UNSTRING Entire-Name DELIMITED BY ‘ ‘ or ‘-’ INTO First-Name Middle-Initial Last-Name.

Substring(nn:nn) position, length 01 whole-name pic x(50). 01first-name pic x(25). move whole-name(1:25) to first-name starts at the first character of whole name and retrieves 25 characters

01 Student-Number PIC 9(9) Comp-3. We would like to print it as

The Long Way File-Section. 05 student-number pic 9(9) comp-3. Working-Storage. 01 student-number-unpacked pic 9(9). 01 Student-number-edited redefines student-number-unpacked.. 05 part1 pic part2 pic part3 pic detail-line. 05 prt-part1 pic pic X value ‘-’. 05 prt-part2 pic pic X value ‘-’. 05 prt-part3 pic 999.

Inspect Verb Used to replace one character or character string with another INSPECT variable REPLACING {ALL} {LEADING} var/lit by var/lit {FIRST}

Print Student Number with ‘-’ using Inspect File-Section. 05 student-number pic 9(9) comp-3. Working-Storage. 01 detail-line. 05 prt-student-number pic 999B999B999. Procedure Division. inspect prt-student-number replacing all ‘ ‘ by ‘-’.

Printing with Externally Described Printer Files New addition to the select statement – FORMATFILE! select report-file assign to formatfile-filename.

Writing to an Externally Described Printer File Write record-name format is ‘RECORD’ eop perform print-heading End-write. (eop means end of page)