Last active
October 17, 2018 12:23
-
-
Save RomanKapitonov/cb69768d85175102c64e055a2e29beeb to your computer and use it in GitHub Desktop.
With static filename assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11111NAME SURNAMEXXXXXXXXXXXXX | |
11112NAME SURNAMEXXXXXXXXXXXXX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cobc -x sample.cob -o sample | |
export DD_STUDENTFILE=input.txt | |
./sample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IDENTIFICATION DIVISION. | |
PROGRAM-ID. HELLO. | |
ENVIRONMENT DIVISION. | |
INPUT-OUTPUT SECTION. | |
FILE-CONTROL. | |
SELECT STUDENT ASSIGN TO STUDENTFILE | |
ORGANIZATION IS LINE SEQUENTIAL. | |
DATA DIVISION. | |
FILE SECTION. | |
FD STUDENT. | |
01 STUDENT-FILE. | |
05 STUDENT-ID PIC 9(5). | |
05 NAME PIC A(25). | |
WORKING-STORAGE SECTION. | |
01 WS-STUDENT. | |
05 WS-STUDENT-ID PIC 9(5). | |
05 WS-NAME PIC A(25). | |
01 WS-EOF PIC A(1). | |
PROCEDURE DIVISION. | |
OPEN INPUT STUDENT. | |
PERFORM UNTIL WS-EOF='Y' | |
READ STUDENT INTO WS-STUDENT | |
AT END MOVE 'Y' TO WS-EOF | |
NOT AT END DISPLAY WS-STUDENT | |
END-READ | |
END-PERFORM. | |
CLOSE STUDENT. | |
STOP RUN. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment