This file contains hidden or 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
MOVE 0 TO CTR. | |
INSPECT TEXT-FIELD TALLYING CTR FOR ALL LEADING ZEROES. |
This file contains hidden or 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
INSPECT PART_NUMBER REPLACING ALL "*" BY "-". |
This file contains hidden or 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
CONVERT-EMPLOYEE-NAME. | |
INSPECT EMPLOYEE-NAME CONVERTING "abcdefghijklmnopqrstuvwxyz" | |
TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ". |
This file contains hidden or 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
WORKING-STORAGE SECTION. | |
01 LONG-FIELD PIC X(20). | |
01 ZIP-CODE PIC X(5). | |
01 LEADING-CTR PIC 99 VALUE 0. | |
01 TRAILING-CTR PIC 99 VALUE 0. | |
01 SPACE-CTR PIC 99 VALUE 0. | |
01 POPULATED PIC 99 VALUE 0. | |
This file contains hidden or 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
READ INPUT-FILE AT END | |
GO TO ALL-DONE. | |
IF INPUT-RECORD (1:17) = "FIRST17CHARACTERS" | |
STOP "RIGHT HERE". |
This file contains hidden or 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
WORKING-STORAGE SECTION. | |
01 WS-CCYYMMDD PIC X(8). | |
01 WS-YYMMDD PIC X(6). | |
01 WS-DATE-IN PIC X(8). | |
01 WS-DATE-IN-NUM REDEFINES WS-DATE-IN PIC 9(8). | |
01 WS-DATE-OUT. | |
05 WS-DATE-OUT-CC PIC XX. | |
05 WS-DATE-OUT-YY PIC XX. | |
05 WS-DATE-OUT-MM PIC XX. |
This file contains hidden or 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
PROCEDURE DIVISION. | |
CALCULATOR-ROUTINE. | |
DISPLAY "COBOL CALCULATOR" LINE 4 POSITION 10 ERASE SCREEN. | |
PERFORM ACCEPT-NUM1. | |
PERFORM ACCEPT-OPERATOR THRU ACCEPT-OPERATOR-EXIT. | |
PERFORM ACCEPT-NUM2. | |
IF OPERATOR = "+" | |
ADD NUM1, NUM2 GIVING RESULT. | |
IF OPERATOR = "-" | |
SUBTRACT NUM2 FROM NUM1 GIVING RESULT. |
This file contains hidden or 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. CALCULATOR. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 NUM1 PIC 9(3) VALUE 0. | |
01 NUM1-TXT PIC X(3) VALUE SPACES. | |
01 NUM2 PIC 9(3) VALUE 0. | |
01 NUM2-TXT PIC X(3) VALUE SPACES. | |
01 RESULT PIC S9(6)V9(2) VALUE 0. | |
01 RESULT-EDIT PIC -ZZZ,ZZ9.99. |
This file contains hidden or 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
WORKING-STORAGE SECTION. | |
01 OLD-DATE PIC X(6) | |
01 NEW-DATE PIC X(8). | |
PROCEDURE-DIVISION. | |
CONVERT-DATE. | |
MOVE OLD-DATE (5:2) TO NEW-DATE (3:2) | |
MOVE OLD-DATE (1:4) TO NEW-DATE (5:4). | |
MOVE "20" TO NEW-DATE (1:2). |
This file contains hidden or 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. CRAZY_CODE_CAFE. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
PROCEDURE DIVISION. | |
ENTER-ROUTINE. | |
PERFORM APPETIZER THRU MAIN-COURSE. | |
DISPLAY "PAY CHECK". | |
STOP RUN. | |
APPETIZER. |