IDENTIFICATION DIVISION. PROGRAM-ID. reschedule-reminders. AUTHOR. Mark Nicholson. * This program reschedules reminders from past days to the current date. It was * written because the contributed library version of REMINDERS automatically deleted * reminders for prior days when it was run and some folks didn't want their reminders * deleted. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT REMINDERS-FILE ASSIGN TO "SYS$LOGIN:REMINDERS." ORGANIZATION IS RELATIVE ACCESS IS SEQUENTIAL . DATA DIVISION. FILE SECTION. FD REMINDERS-FILE RECORD CONTAINS 80 CHARACTERS DATA RECORD IS REMINDER. 01 REMINDER. 02 REM-DATE. 10 REM-DAY PIC 99. 10 FILLER PIC X(01). 10 REM-MONTH PIC X(03). 10 FILLER PIC X(01). 10 REM-YEAR PIC 9999. 02 REM-DATA PIC X(69). WORKING-STORAGE SECTION. 01 CONSTANTS. * MAX-DATE is just a day way out in the future that gets loaded into the reminder record when the "AT END" condition is hit. 05 MAX-DATE PIC X(23) VALUE "31-DEC-2001 00:00:00.00". 01 MISCELLANEOUS-VARIABLES. 05 CURRENT-DATE PIC X(23). 05 BINARY-CURRENT-DATE PICTURE S9(18) COMP. 05 BINARY-REMINDER-DATE PICTURE S9(18) COMP. 05 CONVERT-DATE. 10 CONVERT-DATE-DATE PIC X(11). 10 CONVERT-DATE-TIME PIC X(12) VALUE " 00:00:00.00". PROCEDURE DIVISION. DECLARATIVES. IO-FILE-SECTION SECTION. USE AFTER ERROR PROCEDURE ON REMINDERS-FILE. D0000-PROCESS-FILE-ERRORS. STOP RUN . END DECLARATIVES. MAIN-PROGRAM SECTION. 000-RESCHEDULE-REMINDERS. OPEN I-O REMINDERS-FILE CALL "LIB$DATE_TIME" USING BY DESCRIPTOR CURRENT-DATE CALL "SYS$BINTIM" USING BY DESCRIPTOR CURRENT-DATE BY REFERENCE BINARY-CURRENT-DATE READ REMINDERS-FILE AT END MOVE MAX-DATE TO REM-DATE END-READ PERFORM 100-CONVERT-DATE-TO-BINARY * This loop will go until all prior days reminders have been processed. PERFORM UNTIL BINARY-REMINDER-DATE NOT < BINARY-CURRENT-DATE * The time part of CURRENT-DATE gets truncated in the following move MOVE CURRENT-DATE TO REM-DATE REWRITE REMINDER READ REMINDERS-FILE AT END MOVE MAX-DATE TO REM-DATE END-READ PERFORM 100-CONVERT-DATE-TO-BINARY END-PERFORM CLOSE REMINDERS-FILE STOP RUN . 100-CONVERT-DATE-TO-BINARY. MOVE REM-DATE TO CONVERT-DATE-DATE CALL "SYS$BINTIM" USING BY DESCRIPTOR CONVERT-DATE BY REFERENCE BINARY-REMINDER-DATE .