Lecture 101 String Processing Operations on numeric edited fields i.e., view the PIC as a string of characters –Reference modification read/write substrings.

Slides:



Advertisements
Similar presentations
Structured COBOL Programming
Advertisements

Manipulating Strings String Functions. VB provides a large number of functions that facilitate working with strings. These are found in Microsoft.VisualBasic.Strings.
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
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)
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)
Introduction to Oracle9i: SQL1 Selected Single-Row Functions.
UNIX Filters.
SQL Query Extras MIS 433. Rerunning the last Query n Type the forward slash “/” to rerun the last query that was entered.
Chapter 5 new The Do…Loop Statement
Chapter 3 Elements of Assembly Language. 3.1 Assembly Language Statements.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
FUNCTIONS AND STORED PROCEDURES & FUNCTIONS AND PROTECTING A DB AND PHP (Chapters 9, 15, 18)
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL.
March 12, ICE 1341 – Programming Languages (Lecture #6) In-Young Ko Programming Languages (ICE 1341) Lecture #6 Programming Languages (ICE 1341)
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.
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
Subprograms1 THE CALL STATEMENT (chp. 16) Purpose: a calling that executes another program; allows portions of code to be treated as a “black box”. Syntax.
Chapter 2. C++ Program Structure C++ program is a collection of subprograms Subprograms in C++ are called FUNCTIONS Each function performs a specific.
Oracle 11g: SQL Chapter 10 Selected Single-Row Functions.
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
CS146 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman
Instructor: Craig Duckett Lecture 08: Thursday, October 22 nd, 2015 Patterns, Order of Evaluation, Concatenation, Substrings, Trim, Position 1 BIT275:
Chapter 12: String Manipulation Introduction to Programming with C++ Fourth Edition.
Time to talk about your class projects!. Shell Scripting Awk (lecture 2)
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
Copyright © 2012 Pearson Education, Inc. Chapter 10: Characters, C- Strings, and More About the string Class.
Any Questions? Agenda Level 77 Initialize Display & Accept Arithmetic Verbs Compute statement String/Unstring Inspect.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 9 GEORGE KOUTSOGIANNAKIS Copyright: 2014 Illinois Institute of Technology- George Koutsogiannakis 1.
1 STRINGS String data type Basic operations on strings String functions String procedures.
Basic Variables & Operators Web Programming1. Review: Perl Basics Syntax ► Comments: start with # (ignored by Perl) ► Statements: ends with ; (performed.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 10 Characters, Strings, and the string class.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
© 2006 Lawrenceville Press Slide 1 Chapter 6 The Post-Test Do…Loop Statement  Loop structure that executes a set of statements as long as a condition.
An Introduction to Programming with C++ Sixth Edition Chapter 13 Strings.
11- 1 Chapter 11.  Avoiding Logic Errors by Validating Input  What to Do If Input Errors Occur  Global Considerations in COBOL  When Data Should Be.
1 Predefined Classes and Objects Chapter 3. 2 Objectives You will be able to:  Use predefined classes available in the Java System Library in your own.
ORAFACT Text Processing. ORAFACT Searching Inside Files grep - searches for patterns within files grep [options] [[-e] pattern] filename [...] -n shows.
1 Arrays and Pointers The name of an array is a pointer constant to the first element. Because the array’s name is a pointer constant, its value cannot.
Lab String Concatenation String s3 = s1.concat(s2); String s3 = s1 + s2; s1 + s2 + s3 + s4 + s5 same as (((s1.concat(s2)).concat(s3)).concat(s4)).concat(s5);
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.
There’s a particular style to it… Rob Hatton
Review: A Computational View Programming language common concepts: 1. sequence of instructions -> order of operations important 2. conditional structures.
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
© 2010 Lawrenceville Press Slide 1 Chapter 5 The Do…Loop Statement  Loop structure that executes a set of statements as long as a condition is true. 
Object Files & Linking. Object Sections Compiled code store as object files – Linux : ELF : Extensible Linking Format – Windows : PE : Portable Execution.
LOGICAL CONTROL STRUCTURES (chp. 8)
String Methods Programming Guides.
Chapter 10 Selected Single-Row Functions Oracle 10g: SQL
Java Primer 1: Types, Classes and Operators
String Processing Upsorn Praphamontripong CS 1110
String Processing.
10.1 Character Testing.
Agenda Collating sequence / Sorting data
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Topics discussed in this section:
Basic String Operations
OBJECT ORIENTED PROGRAMMING I LECTURE 9 GEORGE KOUTSOGIANNAKIS
CS 1111 Introduction to Programming Spring 2019
Topics Basic String Operations String Slicing
String Processing 1 MIS 3406 Department of MIS Fox School of Business
Introduction to Computer Science
String Processing.
Python Strings.
Topics Basic String Operations String Slicing
Exam Prep.
Topics Basic String Operations String Slicing
Unit-2 Objects and Classes
Presentation transcript:

lecture 101 String Processing Operations on numeric edited fields i.e., view the PIC as a string of characters –Reference modification read/write substrings –INSPECT replacing, converting, and counting substrings –STRING join substrings –UNSTRING split substrings

lecture 102 Reference Modification (1) Access substrings within a field Format –identifier (offset from left : length) MOVE “*” TO WORK-FIELD (20:1). MOVE SSN (4:2) TO USER-PASSWD (3:2). Omit length to default to the string end MOVE ZIP-CODE TO ADDRESS (15:). Table subscript comes before reference modification TABLE-ITEM (20) (5:1)

lecture 103 Reference Modification (2) 05 TELEPHONE-NUMPIC X(10) VALUE ‘ ’ 01 EDITED-PHONE-NUM. 05 FILLERPIC X VALUE ‘(‘. 05 AREA-CODEPIC X(3). 05 FILLERPIC X VALUE ‘)’. 05 FILLERPIC X VALUE ‘ ‘. 05 EXCHANGEPIC X(3). 05 FILLERPIC X VALUE ‘-’. 05 DIGITSPIC X(4). … MOVE TELEPHONE-NUM (1:3) TO AREA-CODE. MOVE TELEPHONE-NUM (4:3) TO EXCHANGE. MOVE TELEPHONE-NUM (7:4) TO DIGITS.  EDITED-PHONE-NUM = “(614) ”

lecture 104 Utility String Operations Invoke with the statement FUNCTION –NUMVAL – string (‘+’, ‘-’) to number –NUMVAL-C – string (‘$’, ‘,’) to number –LOWER-CASE –UPPER-CASE –LENGTH –REVERSE

lecture 105 INSPECT Operation (1) REPLACING clause INSPECT ident-1 REPLACING {ALL/LEADING/FIRST ident-2/lit-1 BY ident-3/lit-2 {BEFORE/AFTER ident-4/lit-3}} –ALL - replace all occurrences –LEADING – replace occurrences from start –FIRST – replace just first occurrence

lecture 106 INSPECT Operation (2) 01 SSNUMPIC X(9) 01 SSN-OUTPIC XXXBXXBXXXX … MOVE SSNUM TO SSN-OUT. INSPECT SSN-OUT REPLACING ALL ‘ ‘ BY ‘-’ INSPECT WORK-FIELD REPLACING ALL “A” BY “a” BEFORE “.” FIRST “B” BY “b” ALL “C” BY “c” AFTER “.”. WORK-FIELD : “BACK.BACK”  “baCK.BAcK”

lecture 107 INSPECT Operation (3) CONVERTING clause INSPECT ident-1 CONVERTING ident-2/lit-1 TO ident-3/lit-2 {BEFORE/AFTER ident-4/lit-3} INSPECT WORK-FIELD CONVERTING “*” TO “0” WORK-FIELD : “**123.56*”  “ ” TALLYING clause INSPECT ident-1 TALLYING ident-2 FOR { CHARACTERS/ALL/LEADING ident-3/lit-1 {BEFORE/AFTER ident-4/lit-2}} INSPECT WORK-FIELD TALLYING COUNT-1 FOR ALL “*” BEFORE “.” COUNT-2 FOR CHARACTERS AFTER “.”. WORK-FIELD : “***12.**”  COUNT-1 = 3, COUNT-2 = 2

lecture 108 STRING Concatenate substrings into a string STRING {ident-1/lit-1 DELIMITED BY ident-2/lit-2/SIZE} INTO ident-3 WITH POINTER ident-4.

lecture NAME-IN-PIECES. 10 LAST-NAMEPIC X(16). 10 FIRST-NAMEPIC X(10). 10 MIDDLE-INITIALPIC X. 05 ENTIRE-NAMEPIC X(29). SMITH LAST-NAME H MIDDLE-INITIAL JOHN FIRST-NAME ENTIRE-NAME Before Execution

lecture 1010 JOHN (1) ENTIRE-NAME JOHN (b) (2) ENTIRE-NAME Execution Steps JOHN (b) H (3) ENTIRE-NAME JOHN (b) H (4) ENTIRE-NAME JOHN (b) H SMITH (5) ENTIRE-NAME MOVE SPACES TO ENTIRE-NAME. STRING FIRST-NAME DELIMITED BY SPACE ‘ ‘ DELIMITED BY SIZE MIDDLE-INITIAL DELIMITED BY SPACE ‘ ‘ DELIMITED BY SIZE LAST-NAME DELIMITED BY SPACE INTO ENTIRE-NAME

lecture 1011 UNSTRING Split a string into substrings UNSTRING ident-1 { DELIMITED BY {ALL} ident-2/lit-1} INTO ident-list WITH POINTER ident-3

lecture NAME-IN-PIECES. 10 LAST-NAMEPIC X(16). 10 FIRST-NAMEPIC X(10). 10 MIDDLE-INITIALPIC X. 05 ENTIRE-NAMEPIC X(31). LAST-NAME MIDDLE-INITIAL FIRST-NAME Before Execution JOHN (b) H SMITH ENTIRE-NAME MOVE SPACES TO NAME-IN-PIECES. UNSTRING ENTIRE-NAME DELIMITED BY ‘ ‘ INTO FIRST-NAME MIDDLE-INITIAL LAST-NAME.

lecture 1013 JOHN (b) H SMITH (1) ENTIRE-NAME JOHN (b) H SMITH (1) ENTIRE-NAME JOHN H SMITH FIRST-NAMELAST-NAMEMIDDLE-INITIAL

lecture 1014 Subprograms What is a subprogram? –cobol code in different file(s) –pre-compiled –call from within your program Why? –fast linking with your program –shared by many applications –basis for libraries of useful code

lecture 1015 Subprogram Format A subprogram is the same as a program except : –extra program division called LINKAGE SECTION. –PROCEDURE DIVISION has a USING clause –EXIT PROGRAM instead of STOP RUN. … LINKAGE SECTION. … Data definitions for fields coming from the calling program … … PROCEDURE DIVISON USING ident-1 … … EXIT PROGRAM.

lecture 1016 Calling the Subprogram CALL “subprogram-name” USING ident-1 … In the subprogram, the fields in the LINKAGE SECTION must match the list in the USING clause of the PROCEDURE DIVISION The lists in both USING clauses of CALL and the PROCEDURE DIVISON must match See the book for an example