HP3000-L Archives

May 1995, 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:
Glenn Mitchell <[log in to unmask]>
Reply To:
Date:
Wed, 17 May 1995 08:55:00 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (32 lines)
Tom Hoefner writes:
 
>OK ALL YOU COBOL GURUS, PLEASE REFRESH MY MEMORY.
>
>.....WORKING-STORAGE SECTION.
>
>01  NEXT-YRSEM        PIC 9(3).
>
>....down in PROCEDURE DIVISION......
>
>IF NEXT-YRSEM = "Y"
>   .................
>
>This is a definite bug in the particular system.   How come the Native Mode
>compiler did not throw this out as an ILLEGAL COMPARE or similar?
 
This is a perfectly legal comparison in COBOL according to the 1985 ANSI
standard.  An integer numeric operand can be compared to a nonnumeric
operand providing that their usage is the same (in this case DISPLAY).  In this
case the literal "Y" is effectually extended to the right with two bytes of spaces
and the resulting literal is compared with the three bytes of NEXT-YRSEM.
 
Nevertheless, the code stinks.  If NEXT-YRSEM is allowed to take on nonnumeric
values, it should be defined PIC X(3).  If not, the comparison is out in left field.
 
Hope this helps.
 
Glenn Mitchell
Maine Medical Center
Portland, ME
[log in to unmask]

ATOM RSS1 RSS2