Problem: When compiling a program, the following error is reported by the compiler: Operand time-of-day is not declared Resolution: In both the Server Express documentation and the Visual COBOL documentation, the special register TIME-OF-DAY is documented as being applicable to the OSVS dialect. In addition, the documentation generally says: TIME-OF-DAY 9(6) DISPLAY The TIME-OF-DAY special register contains the value of the current time of day (24-hour clock) (as supplied by the COBOL execution environment), in the form: hhmmss where hh =hour, mm=minutes, and ss= seconds. TIME-OF-DAY is valid only as the sending area of a MOVE statement. Based on the above, here is a sample program I wrote to test this: 000001 IDENTIFICATION DIVISION. 000002 PROGRAM-ID. TOD-TEST. 000003 ENVIRONMENT DIVISION. 000004 CONFIGURATION SECTION. 000005 DATA DIVISION. 000006 WORKING-STORAGE SECTION. 000007 01 TIME-OF-DAY-WS PIC 9(6). 000008 PROCEDURE DIVISION. 000009 MOVE TIME-OF-DAY TO TIME-OF-DAY-WS. 000010 DISPLAY 'TIME-OF-DAY IS ' TIME-OF-DAY-WS. 000011 STOP RUN. This compiles successfully under Visual COBOL, and also under Server Express, if and only if one the following compiler directives is specified: OSVS or DOSVS or DIALECT"OSVS" or DIALECT"DOSVS". Here are example command lines: $ cob TOD-TEST.cbl -- Fails 9 MOVE TIME-OF-DAY TO TIME-OF-DAY-WS. * 12-S******************** ** ** Operand TIME-OF-DAY is not declared cob32: error(s) in compilation: TOD-TEST.cbl $ cob -C OSVS TOD-TEST.cbl -- Succeeds $ cob -C DOSVS TOD-TEST.cbl -- Succeeds $ cob -C DIALECT=OSVS TOD-TEST.cbl -- Succeeds $ cob -C DIALECT=DOSVS TOD-TEST.cbl -- Succeeds To make it work with Visual COBOL, specify the OSVS compiler directive, or within a Visual COBOL for Eclipse project, under Properties Micro Focus Project Settings COBOL, in the drop-down named "Language dialect", select "OS/VS COBOL".
↧