« Cobol ANS 74 » : différence entre les versions

2 071 octets ajoutés ,  il y a 15 ans
 
== Un exemple de programme COBOL ==
<pre>
1 2 3 4 5 6 7
123456789012345678901234567890123456789012345678901234567890123456789012
 
IDENTIFICATION DIVISION.
PROGRAM-ID. EXEMPLE.
AUTHOR. SMITH.
DATE-WRITTEN. 25 SEP 1988.
 
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. MINTA.
OBJECT-COMPUTER. MINTA.
INPUT_OUTPUT SECTION.
FILE_CONTROL.
SELECT FICHIER1 ASSIGN TO CARD-READER.
SELECT FICHIER2 ASSIGN TO PRINTER.
 
DATA DIVISION.
FILE SECTION.
FD FICHIER1 LABEL RECORD IS OMITTED
DATA RECORD IS COMMERCE.
01 COMMERCE.
02 IMPORT.
03 MECANIQUE PICTURE 9(5).
03 ELECTRIQUE PICTURE 9(5).
02 EXPORT.
03 ALIMENTAIRE PICTURE 9(5).
03 DIVERS PICTURE 9(5).
FD FICHIER2 LABEL RECORD IS OMITTED
DATA RECORD IS STAT_COMMERCE.
01 STAT°COMMERCE.
02 FILLER PICTURE X(3); VALUE SPACE.
02 EXP_IMP PICTURE 9(5).
02 PCT_MECA PICTURE 9.99.
02 PCT_ALIM PICTURE 9.99.
WORKING-STORAGE SECTION.
77 FLAG PICTURE 9.
 
PROCEDURE DIVISION.
PROG.
PERFORM D-PROG.
PERFORM LECTURE-CALCUL-ECRITURE UNTIL FLAG = 1.
PERFORM F-PROG;
STOP RUN.
D-PROG.
OPEN INPUT FICHIER1.
OPEN OUTPUT FICHIER2.
MOVE 0 TO FLAG.
READ FICHIER1 AT END MOVE 1 TO FLAG.
LECTURE-CALCUL-ECRITURE.
COMPUTE EXP-IMP = ALIMENTAIRE + DIVERS - MECANIQUE -
ELECTRIQUE.
COMPUTE PCT_MECA = MECANIQUE / (MECANIQUE + ELECTRIQUE).
COMPUTE PCT-COMMERCE AFTER ADVANCING 1 LINE.
WRITE STAT-COMMERCE AFTER ADVANCING 1 LINE.
READ FICHIER1 AT END MOVE 1 TO FLAG.
F-PROG.
CLOSE FICHIER1, FICHIER2.
</pre>
 
= Structure d'un programme =
2 453

modifications