For Programmers: Free Programming Magazines  


Home > Archive > Cobol > January 2008 > Re: checking if NUMERIC









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: checking if NUMERIC
Pete Dashwood

2008-01-26, 6:56 pm



"Clark F Morris" <cfmpublic@ns.sympatico.ca> wrote in message
news:5phnp39cnk3nd7vc4nsi2flb4psm9emmco@
4ax.com...
> On Sun, 21 Oct 2007 18:33:22 +1300, "Pete Dashwood"
> <dashwood@removethis.enternet.co.nz> wrote:
>
>
> As someone who has used COBOL since May 1963 (RCA 301, after that
> varying flavors of IBM COBOL), I have always used it such that input
> field were defined as expected and done the test accordingly. In the
> case of numerics with sign overpunches, the picture (or SIZE and CLASS
> in the Codasyl COBOL 61 I started with) determined how the IF NUMERIC
> would work.


I started with COBOL 61 as well :-) You forgot to mention that, prior to the
introduction of PICTURE, data was defined with SIZE, CLASS, and *USAGE*
clauses.

>I assumed the input from cards could be bad


Yep, me too... and it very often was :-)

>and thus
> tested it using the descriptions of the fields as I wanted them.


Well, I did it similarly, ensuring the input record was defined with what
was required, but then testing each supposedly numeric field in an AN field.
If they all passed, it was safe to proceed. My programs did this stuff in a
VALIDATE-INPUT SECTION. It worked pretty well and I seldom had 0c7 crashes
caused by bad input (usually it was bad programming... Ah, happy days, when
we were learning...:-))

> Given
> that an alphanumeric field could not be easily moved to a signed
> field, I doubt that the intent was to have all input in Alphanumeric
> fields.


Maybe. The problem was that with packed fields as soon as you tried to use
them, you'd crash with 0c7. It therefore was better to ensure that what you
stored there was valid...
[color=darkred]

Pete.
--
"I used to write COBOL...now I can do anything."


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com