Microsoft KB Archive/40858

How to ACCEPT identifier FROM DAY-OF-WEEK, Sunday to Saturday

PSS ID Number: Q40858 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: Microsoft COBOL Versions 3.0 and 3.0a follow the ANSII 85 standard, which includes DAY-OF-WEEK. The reserved word DAY-OF-WEEK is a special register that contains the day of the week as a number. The number varies from 0 for Sunday to 6 for Saturday. DAY-OF-WEEK is not available in versions of Microsoft COBOL earlier than Version 3.0. DAY-OF-WEEK needs to be added to the list of conceptual data items (such as DATE, DAY, TIME) listed for the Format 2 ACCEPT statement on Page 3-86 of the “Microsoft COBOL Version 3.0: Language Reference Manual,” as follows: ACCEPT identifier FROM DAY-OF-WEEK

More Information: The program example shown below, which gives an example of using DAY-OF-WEEK, can be compiled with no COBOL.DIR and no special linking. The compile step: COBOL prognam.cbl; The LINK step: LINK Prognam.obj; The following is the example code: $SET ANS85 WORKING-STORAGE SECTION. 01 TheDay PIC 9. 01 DAY-LIST. 05 PIC X(9) VALUE “SUNDAY”. 05 PIC X(9) VALUE “MONDAY”. 05 PIC X(9) VALUE “TUESDAY”. 05 PIC X(9) VALUE “WEDNESDAY”. 05 PIC X(9) VALUE “THURSDAY”. 05 PIC X(9) VALUE “FRIDAY”. 05 PIC X(9) VALUE “SATURDAY”. 01 DAY-TABLE REDEFINES DAY-LIST. 05 WEEK-DAY PIC X(9) OCCURS 7 TIMES. PROCEDURE DIVISION. ACCEPT TheDay FROM DAY-OF-WEEK. ADD 1 TO TheDay. DISPLAY “THE DAY OF THE WEEK IS”, WEEK-DAY (TheDay). STOP RUN.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.