Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

concatenating unknown-length strings in COBOL

Tags:

string

cobol

How do I concatenate together two strings, of unknown length, in COBOL? So for example:

WORKING-STORAGE.
    FIRST-NAME    PIC X(15) VALUE SPACES.
    LAST-NAME     PIC X(15) VALUE SPACES.
    FULL-NAME     PIC X(31) VALUE SPACES.

If FIRST-NAME = 'JOHN ' and LAST-NAME = 'DOE ', how can I get:

FULL-NAME = 'JOHN DOE                       '

as opposed to:

FULL-NAME = 'JOHN            DOE            '
like image 305
Eric H Avatar asked Mar 02 '23 08:03

Eric H


1 Answers

I believe the following will give you what you desire.

STRING
FIRST-NAME DELIMITED BY " ",
" ",
LAST-NAME DELIMITED BY SIZE
INTO FULL-NAME.
like image 61
Thayne Avatar answered Apr 03 '23 16:04

Thayne