HP3000-L Archives

October 2004, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Emerson, Tom" <[log in to unmask]>
Reply To:
Emerson, Tom
Date:
Mon, 18 Oct 2004 17:12:20 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
> -----Original Message-----
> Behalf Of Brian Donaldson
> 
> I have been using CALENDAR and ALMANAC intrinsics in Cobol programs
> I wrote a quickie program to satisfy my own curiosity
>  WORKING-STORAGE SECTION.
>  01  WS-YEAR-NUM             PIC S9(04) COMP VALUE ZEROES.
>  01  WS-MONTH-NUM            PIC S9(04) COMP VALUE ZEROES.
>  01  WS-START-DATE           PIC  9(04) COMP VALUE ZEROES.
> 
>      CALL INTRINSIC "CALENDAR" GIVING WS-START-DATE.
>      CALL INTRINSIC "ALMANAC" USING WS-START-DATE,
[...]
> YEAR    IS=>+0104<
> MONTH   IS=>+0010<
> Add 1900 to the year and you get 2004. Fine.
> The month is 10 (October). Fine.
[...]
> This works fine.....
> 
> So what's the problem........??

I suspect the "problem" is that you didn't make the mistake of looking directly at the intermediate result held in the variable "WS-START-DATE" -- as others have mentioned, the ACTUAL value this contains is -11996, which COBOL will mangle should you attempt to display it (truncating to 1996, and possibly dropping the sign bit in the process)

Sure enough, adding a display of WS-START-DATE between the two calls results in this output:

988/COREDEV/TEMPTE:cob85xlg.pub.sys junk1
PAGE 0001  COBOL II/iX HP31500A.04.20  [85] Copyright Hewlett-Packard CO. 1987
[snip...]
 00029 te041018 003000     CALL INTRINSIC "CALENDAR" GIVING WS-START-DATE.
 00035 te041018 003010
 00036 te041018 003020     display "Intermediate result: " WS-START-DATE
 00037 te041018 003030
 00039 te041018 003100     CALL INTRINSIC "ALMANAC" USING WS-START-DATE,
[snap...]
END OF LINK

Intermediate result: 1996
YEAR    IS=>+0104<
MONTH   IS=>+0010<
DAY     IS=>+0018<
WEEKDAY IS=>+0002<

END OF PROGRAM

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2