Archives par mot-clé : INSPECT CONVERTING

Exemple – INSPECT CONVERTING

Voici un programme utilisant le INSPECT CONVERTING :

IDENTIFICATION DIVISION.
PROGRAM-ID.  INSPECT.
AUTHOR.      LA COMMUNAUTE DU COBOL.

ENVIRONMENT DIVISION.                                            
CONFIGURATION SECTION.                                           
SPECIAL-NAMES.                                                   
    DECIMAL-POINT IS COMMA. 

DATA DIVISION.
WORKING-STORAGE SECTION.

01  WS-AUXILIARES.
    05  ITEM-1          PIC X(016) VALUE 'AC"AEBDFBCD#AB"D'. 
    05  ITEM-2          PIC X(026) VALUE "ABCDEFGHIJKLMNOPQRSTUVWXYZ".

PROCEDURE DIVISION.

001-INIT.

    DISPLAY "ITEM-1 AVANT  : " ITEM-1
    INSPECT ITEM-1 CONVERTING
            "ABCD" TO "XYZX" AFTER QUOTE BEFORE "#"
    DISPLAY "ITEM-1 APRES  : " ITEM-1

    DISPLAY "ITEM-2 AVANT  : " ITEM-2
    INSPECT ITEM-2 CONVERTING "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
                           TO "abcdefghijklmnopqrstuvwxyz"
    DISPLAY "ITEM-2 APRES  : " ITEM-2
    STOP RUN.

* Resultat de test:

* ITEM-1 AVANT  : AC"AEBDFBCD#AB"D
* ITEM-1 APRES  : AC"XEYXFYZX#AB"D

* ITEM-2 AVANT  : ABCDEFGHIJKLMNOPQRSTUVWXYZ
* ITEM-2 APRES  : abcdefghijklmnopqrstuvwxyz