Text Manipulation - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Text Manipulation

Description:

05 FULL-NAME PIC X(20) VALUE JOHN SMITH'. 05 FIRST-NAME PIC X(10) VALUE SPACE. ... 10 LAST-NAME PIC X(10) VALUE SMITH . 10 MIDDLE-INIT PIC X(01) VALUE K. ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 8
Provided by: dennis224
Category:

less

Transcript and Presenter's Notes

Title: Text Manipulation


1
Text Manipulation
2
Reference Modification (page 230)
  • Defines a data item by specifying a leftmost
    character and an optional length for the data
    item
  • is of the form VAR1(ab) , where
  • a gt specifies the start, and can be an integer
    or a variable
  • b gt specifies an optional length can be an
    integer or a variable
  • Example 1
  • 05 PHONE-NUM PIC X(10) VALUE 4165551234.
  • 05 AREA-CODE PIC X(03) VALUE 905.
  • MOVE AREA-CODE TO PHONE-NUM(13)
  • Example 2
  • 05 PHONE-NUM PIC X(10) VALUE 4165551234.
  • 05 AREA-CODE PIC X(03) VALUE 905.
  • MOVE AREA-CODE(22) TO PHONE-NUM(34)

3
Reference Modification (page 230)
  • Example 3
  • 05 FULL-NAME PIC X(20) VALUE JOHN SMITH.
  • 05 FIRST-NAME PIC X(10) VALUE SPACE.
  • 05 X1 PIC S9(05) PACKED-DECIMAL VALUE
    ZERO.
  • 05 X2 PIC S9(05) PACKED-DECIMAL VALUE
    ZERO.
  • PERFORM
  • VARYING X1 FROM 1 BY 1
  • UNTIL X1 gt 20
  • IF FULL-NAME (X11) SPACE
  • THEN
  • MOVE 21 TO X1
  • ELSE
  • ADD 1 TO X2
  • MOVE FULL-NAME (X11) TO FIRST-NAME
    (X21)
  • END-IF
  • END-PERFORM

4
STRING Statement (page 231)
  • Rules
  • 1. The DELIMITED BY clause is required. It can
    indicate
  • SIZE The entire sending field is transmitted
  • Literal The transfer of data is terminated when
    the specified literal is encountered the literal
    itself IS NOT MOVED
  • Identifier The transfer of data is terminated
    when the content of the identifier is encountered
  • The receiving field must be an elementary data
    item
  • All literals must be PIC X
  • The string moves data from left to right, but
    does not pad with low-order blanks
  • Syntax
  • STRING identifier-1 / literal-1 . . .
  • DELIMITED BY identifier-2 / literal-2 / SIZE
  • INTO identifier-3
  • END-STRING

5
STRING Statement (page 231)
  • Example 1
  • 05 STUDENT-NAME.
  • 10 FIRST-NAME PIC X(10) VALUE PAUL .
  • 10 LAST-NAME PIC X(10) VALUE SMITH .
  • 10 MIDDLE-INIT PIC X(01) VALUE K.
  • 05 STUDENT-NAME-OUT PIC X(25).
  • STRING
  • FIRST-NAME DELIMITED BY
  • MIDDLE-INIT DELIMITED BY SIZE
  • LAST-NAME DELIMITED BY SPACE
  • INTO STUDENT-NAME-OUT
  • END-STRING

6
STRING Statement (page 231)
  • Example 2
  • 05 STUDENT-NAME.
  • 10 FIRST-NAME PIC X(10) VALUE PAUL .
  • 10 LAST-NAME PIC X(10) VALUE SMITH .
  • 10 MIDDLE-INIT PIC X(01) VALUE K.
  • 05 STUDENT-NAME-OUT PIC X(25).
  • STRING
  • FIRST-NAME DELIMITED BY
  • DELIMITED BY SIZE
  • MIDDLE-INIT DELIMITED BY SIZE
  • . DELIMITED BY SIZE
  • LAST-NAME DELIMITED BY
  • INTO STUDENT-NAME-OUT
  • END-STRING

7
STRING Statement (page 231)
  • Example 3
  • 05 B PIC X(03) VALUE ABC'.
  • 05 Z PIC X(14) VALUE SPACE.
  • MOVE '12345678901234' TO Z
  • STRING
  • B DELIMITED BY SIZE
  • INTO Z
  • END-STRING
Write a Comment
User Comments (0)
About PowerShow.com