Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
000001 IDENTIFICATION DIVISION.
000002 PROGRAM-ID. RSQ.
000003 ENVIRONMENT DIVISION.
000004 INPUT-OUTPUT SECTION.
000005 FILE-CONTROL.
000006 SELECT A ASSIGN TO DISK FILE-NAME
000007 ORGANIZATION LINE SEQUENTIAL.
000008 DATA DIVISION.
000009 FILE SECTION.
000010 FD A RECORD IS VARYING IN SIZE FROM 0 TO 256 CHARACTERS
000011 DEPENDING ON L-REC-A.
000012 01 A-REC-21.
000013 02 A-1-6 PIC 9(6).
000014 02 A-7-7 PIC X(1).
000015 02 A-8-21 PIC X(14).
000016 01 A-REC PIC X(256).
000017 WORKING-STORAGE SECTION.
000018 01 EOJ PIC 9 VALUE 0.
000019 01 O-K PIC X.
000020 01 SW-FUNCTION-X.
000021 03 SW-FUNCTION-1 PIC X.
000022 03 SW-FUNCTION-2 PIC X.
000023 01 SW-FUNCTION REDEFINES SW-FUNCTION-X PIC XX.
000024 01 SW-FUNCTION-9 REDEFINES SW-FUNCTION PIC 99.
000025 01 SW-SPACE PIC 9 VALUE 0.
000026 01 SW-DOT PIC 9 VALUE 0.
000027 01 L-REC-A PIC 9999 COMP.
000028 01 I PIC 9(2) COMP.
000029 01 J PIC 9(2) COMP.
000030 01 H PIC 9(2) COMP.
000031 01 K PIC 9(2) COMP.
000032 01 L PIC 9(2) COMP.
000033 01 M PIC 9(2) COMP.
000034 01 N PIC 9(2) COMP.
000035 01 X PIC X.
000036 01 COUNTER-READ-X.
000037 02 FILLER PIC 9(4) VALUE 0.
000038 02 COUNTER-1 PIC 99 VALUE 0.
000039 01 COUNTER-READ REDEFINES COUNTER-READ-X PIC 9(6).
000040 01 COUNTER-WRITE PIC 9(6) VALUE 0.
000041 01 FILE-NAME PIC X(64) VALUE SPACES.
000042 01 FILE-NAME-R REDEFINES FILE-NAME.
000043 02 VEC-FILE-NAME PIC X OCCURS 64.
000044 01 FILE-NAME1 PIC X(60) VALUE SPACES.
000045 01 FILE-NAME1-R REDEFINES FILE-NAME1.
000046 02 VEC-FILE-NAME1 PIC X OCCURS 60.
000047*********************************************************************
000048 PROCEDURE DIVISION.
000049 MAIN SECTION.
000050 1. PERFORM PROC-BEGIN THRU EX-PROC-BEGIN.
000051 PERFORM PROC-MAIN THRU EX-PROC-MAIN UNTIL EOJ > 0.
000052 PERFORM PROC-END THRU EX-PROC-END.
000053 STOP RUN.
000054 EX-PROC-MAIN-SECTION.
000055 PROC-BEGIN.
000056 PERFORM IN-COMMAND-LINE.
000057 IF O-K = "@" MOVE 2 TO EOJ, GO TO EX-PROC-BEGIN.
000058 PERFORM IF-COBOL THRU EX-IF-COBOL.
000059 IF EOJ > 0 GO TO EX-PROC-BEGIN.
000060 MOVE 0 TO EOJ COUNTER-READ COUNTER-WRITE.
000061 OPEN I-O A.
000062 PERFORM READ-A THRU EX-READ-A.
000063 EX-PROC-BEGIN.
000064 IN-COMMAND-LINE.
000065 ACCEPT FILE-NAME1 FROM COMMAND-LINE.
000066 IF FILE-NAME1 = SPACES
000067 PERFORM IN-FILE-NAME THRU EX-IN-FILE-NAME.
000068 MOVE 0 TO SW-SPACE SW-DOT J.
000069 MOVE SPACES TO FILE-NAME.
000070 PERFORM IN-COMMAND-LINE1 THRU EX-IN-COMMAND-LINE
000071 VARYING I FROM 1 BY 1 UNTIL I > 60.
000072 IF SW-DOT = 0
000073 STRING FILE-NAME DELIMITED BY SPACE
000074 ".CBL" DELIMITED BY SIZE INTO FILE-NAME.
000075 IN-COMMAND-LINE1.
000076 MOVE VEC-FILE-NAME1(I) TO X.
000077 IF X = SPACE IF SW-SPACE = 0 GO TO EX-IN-COMMAND-LINE
000078 ELSE MOVE 88 TO I
000079 GO TO EX-IN-COMMAND-LINE
000080 ELSE IF X = "." MOVE 1 TO SW-DOT, END-IF
000081 IF SW-SPACE = 0 MOVE 1 TO SW-SPACE, END-IF
000082 ADD 1 TO J
000083 MOVE X TO VEC-FILE-NAME(J).
000084 EX-IN-COMMAND-LINE.
000085 IN-FILE-NAME.
000086 DISPLAY "ENTER COBOL PROGRAM:' ' O-K:' ' (Y-Y@
000087- "ES, N-NO, @-EXIT) " LINE 24 ERASE.
000088 DISPLAY FILE-NAME1 LINE 24 POSITION 22 WITH SIZE 20.
000089 ACCEPT FILE-NAME1 LINE 24 POSITION 22 WITH SIZE 20.
000090 IF FILE-NAME1 = SPACES GO TO IN-FILE-NAME.
000091 IN-FILE-NAME1.
000092 ACCEPT O-K LINE 24 POSITION 44.
000093 IF O-K = "N" GO TO IN-FILE-NAME.
000094 IF O-K = "@" MOVE FILE-NAME TO FILE-NAME1
000095 GO TO EX-IN-FILE-NAME.
000096 IF O-K NOT = "Y" GO TO IN-FILE-NAME1.
000097 DISPLAY SPACE.
000098 EX-IN-FILE-NAME.
000099 IF-COBOL.
000100 OPEN INPUT A.
000101 IF-COBOL1.
000102 PERFORM READ-A THRU EX-READ-A.
000103 IF EOJ > 0 GO TO IF-COBOL2.
000104 IF COUNTER-READ > 50 GO TO IF-COBOL1.
000105 IF A-8-21 = "IDENTIFICATION" CLOSE A, GO TO EX-IF-COBOL.
000106 GO TO IF-COBOL1.
000107 IF-COBOL2.
000108 DISPLAY "NO COBOL PROGRAM"
000109 CLOSE A.
000110 MOVE 3 TO EOJ.
000111 EX-IF-COBOL.
000112 PROC-MAIN.
000113 PERFORM REWRITE-A THRU EX-REWRITE-A.
000114 PERFORM READ-A THRU EX-READ-A.
000115 EX-PROC-MAIN.
000116 READ-A.
000117 MOVE SPACES TO A-REC.
000118 READ A AT END MOVE 1 TO EOJ
000119 GO TO EX-READ-A.
000120 ADD 1 TO COUNTER-READ.
000121 IF COUNTER-1 = 0 DISPLAY COUNTER-READ "/" COUNTER-WRITE.
000122 EX-READ-A.
000123 REWRITE-A.
000124 IF L-REC-A < 6 GO TO EX-REWRITE-A.
000125 MOVE COUNTER-READ TO A-1-6.
000126 REWRITE A-REC.
000127 ADD 1 TO COUNTER-WRITE.
000128 EX-REWRITE-A.
000129 PROC-END.
000130 IF EOJ > 1 GO TO EX-PROC-END.
000131 DISPLAY "READ: " COUNTER-READ.
000132 DISPLAY "WRITE:" COUNTER-WRITE.
000133 CLOSE A.
000134 EX-PROC-END.
000135*****************************************************************