Sie sind auf Seite 1von 26

STRING Verb

- This verb is used to concatenate two or more


strings.

String

identifier-1
literal-1

Delimited by

Delimited by

Into identifier-7

identifier-3
literal-3
size

identifier-2
literal-2

identifier-4
literal-4

identifier-6
literal-6
size

with pointer identifier-8

; on overflow imperative-statement

identifier-5
literal-5

Example
Let us consider the following Data Division entries
77
77
77
77

FIELD-1
FIELD-2
FIELD-3
DATA

PIC
PIC
PIC
PIC

X(4)
X(6)
X(9)
X(14)

VALUE
VALUE
VALUE
VALUE

ABCD.
MA IN.
121,34,56.
SPACES .

The statement is
STRING FIELD-1, FIELD-2, FIELD-3 DELIMITED BY
, , INTO DATA.

INSPECT verb
The INSPECT verb enables the programmer
to tally and/or replace the occurrences of a single
character or groups of characters in a data field.

INSPECT

identifier-1

identifier-2

TALLYING

FOR
,

ALL
LEADING
CHRACTERS

BEFORE
INITIAL
AFTER

identifier-4
literal-2

identifier-3
literal-1

Example
Let us consider the following Data Division entries
77

FIELD-1

77

DATA

PIC
PIC

X(20) VALUE
ANANTAKUMARMAITY.
X(2).

The statement Is

INSPECT

FIELD-1

TALLYING

DATA

FOR

ALL A .

INSPECT
CHARACTERS

identifier-1
BY

ALL
LEADING
FIRST

identifier-2
literal-1

identifier-4
literal-3

BEFORE

REPLACING
BEFORE
AFTER

BY

identifier-3
literal-2

identifier-5
literal-4

identifier-6
INITIAL

AFTER

INITIAL

..
literal-5

Example
Let us consider the following Data Division entries
77

FIELD-1

77

DATA

PIC
PIC

X(20) VALUE
ANANTAKUMARMAITY.
X(2).

The statement Is

INSPECT

FIELD-1

REPLACING

ALL

BY

..

Other forms of INSPECT verb.


INSPECT identifier-1 TALLYING
< tallying part as in option 1 >
REPLACING
< replacing part as in option 2 >

INSPECT

identifier-1

TO

CONVERTING

identifier -3
literal-2

identifier-2
literal-1

UNSTRING Verb
- It splits larger string to smaller parts or
sub-strings .

UNSTRING

identifier-1

DELIMITED BY [ ALL ]

identifier-2

, OR [ ALL ]

identifier-3

literal-1

INTO

literal-2

identifier-4 [ , DELIMITER IN identifier-5 ]


[ , COUNT IN identifier-6 ]

[ WITH POINTER identifier-7 ]


[ TALLYING IN identifier-8 ] [ ; on overflow imperative-statement ]

Example
Let us consider the following Data Division entries
77
77
77
77

FIELD-1
FIELD-2
FIELD-3
DATA

PIC
PIC
PIC
PIC

X(5).
X(5).
X(5).
X(15) VALUE IS
ABCDEFGCCHIJKCL.

The statement is
UNSTRING DATA DELIMITED BY C
INTO FIELD-1, FILED-2, FIELD-3.

Reference Modification
It is similar to unstring.
The general syntax is ,

data-name ( starting position : [length] )

Here the length specification is optional.

Example
Let us consider the following data description entry
05 DATA-FIELD PIC X(11) VALUE MATHEMATICS
05 OLD-FIELD
PIC X(05).
Now the statement
MOVE

DATA-FIELD (4 : 2) TO OLD-FIELD.

COPY

verb

COPY

text-name

REPLACING

OF
IN

= = pseudo-text-1 = =
identifier-1
literal-1
word-1
= = pseudo-text-3 = =
identifier-3
literal-3
word-3

library-name

BY

BY

= = pseudo-text-2 = =
identifier-2
literal -2
word-2
= = pseudo-text-4 = =
identifier-4
literal-4
word-4

Example
Let TEXT be the name of the following text in the library file.
RECORD CONTAINS 130 CHARACTERS
BLOCK CONTAINS 10 RECORDS
LABLE RECORDS ARE STANDARD
VALUE OF ID IS FILE.
Now the following code
FD FILE-MASTER
COPY TEXT.
At the time of compilation , it will become
FD FILE-MASTER
RECORD CONTAINS 130 CHARACTERS
BLOCK CONTAINS 10 RECORDS
LABLE RECORDS ARE STANDARD
VALUE OF ID IS FILE.

INITIALIZE

verb

Used for Setting Numeric Fields to Zeroes and NonNumeric Fields to Spaces.

INITIALIZE Verb Serves as a Convenient Alternative


to the Use of MOVE in PROCEDURE DIVISION.

Using REPLACING Option With INITIALIZE Verb


We can Set Alphanumeric Fields Other Than Spaces,
Numeric Fields Other Than Zeroes

INITIALIZE { identifier-1 } .

REPLACING

DATA

BY

ALPHABETIC
ALPHANUMERIC
NUMERIC
ALPHANUMERIC-EDITED
NUMERIC-EDITED

identifier -2
literal-1

Example
Let us consider the following Data Division entries
01

A.
02
02
02

B
C
D

PIC
PIC
PIC

A(2).
X(2).
9(2).

The statement is
INITIALIZE A REPLACING
ALPHABETIC DATA BY NO
ALPHANUMERIC DATA BY N
NUMERIC DATA BY 0.

REDEFINES

Clause

The REDEFINES clause allows you to use different


data description entries to describe the same computer
storage area.

Allows to Share the Same Main Storage Area to Refer


to Different Data Description. The Idea is to Use the
Main Storage Efficiently.

Example

01 CUSTOMER-RECORD.
05 CUST-NO
PIC 999.
05 CUST-NAME PIC X(15).
05 CUST-TEL-NO
PIC 9(7).
01 SALES-RECORD REDEFINES
CUSTOMER-RECORD.

05 CUST-NAME PIC X(10).


05 CUST-CREDIT
PIC 9(04).
05 CUST-CITY PIC 9(10).
05 FILLER
PIC X(01).

EVALUATE Verb
- It depicts the CASE structure.

EVALUATE subject-1 [ ALSO subject-2 ] .


{ { WHEN object-1 [ ALSO object-2 ] . }
imperative statements-1 }.
[ WHEN OTHER imperative statements-2 ] [ END-EVALUATE ]
where a subject is
identifier
literal
expression
TRUE
False
and an object is
ANY
condition
TRUE
FALSE
[ NOT ]

identifier-1
literal-1
arithmetic-expr-1

THROUGH
THRU

identifier-2
literal-2
arithmetic-expr-2

Example
EVALUATE TRUE
WHEN MONTH = 4 OR 6 OR 9 OR 11
MOVE 30 TO NO-OF-DAYS
WHEN MONTH = 2
MOVE 28 TO NO-OF-DAYS
WHEN OTHER MOVE 31 TO NO-OF-DAYS
END-EVALUATE.

Thank You

Das könnte Ihnen auch gefallen