bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] possibly bug: accept into numeric field


From: Thomas Biehler
Subject: Re: [open-cobol-list] possibly bug: accept into numeric field
Date: Fri Nov 14 07:20:13 2003
User-agent: KMail/1.4.3

> > But after visiting the results i must repeat me!
> > Finding out what "the standard" (really) means and implement it
> > should be the very first step. After that, other "important
> > compiler-dialects" could (or shoúld ?)  be supported. (or the "average of
> > all" :-) )
>
> Sure.  But it seems that the standard does not explicitly specify
> how numeric accept should work.  I think implementing the "intuitive"
> behavior is good enough here.

Ok!

> > COBOL-85 Compiler on DPS-7000 (GCOS-7) System:  (handy programmed tests)
> > ====================================================
> > Data-Item               Input
> > 01 X-1 PIC 99.       123
> > ==> Result:       Error-Message :  "Maximum Value 99: Please reenter"
> > 01 X-2 PIC 99V9.   1
> > ==> Result:       010  (as expected)
> > 01 X-3 PIC 99V9.   123.4
> > ==> Result:       Error-Message :  "Maximum Value 99.9: Please reenter"
>
> OK, let's make this the default behavior for terminal input.
> We still need to think about non-terminal input (like redirection
> on Unix), though.

Ok !

> > tiny-cobol 0.61 (with some but not all updates from CVS)
> > ===================================================
> >
> > PLEASE GIVE IN VALUE  123  in X-1  (PIC 99) :
> > 123
> > VALUE OF X-1: /23/                   <=== Ooops!
> >
> > PLEASE GIVE IN VALUE  1  in X-2  (PIC 99V9) :
> > 1
> > VALUE OF X-2: /01.0/
> >
> > PLEASE GIVE IN VALUE  123.4  in X-3  (PIC 99V9) :
> > 123.4
> > VALUE OF X-3: /23.4/               <=== ???
>
> This is easy to implement.  The following definition of cob_accept
> will work as "alphanumeric to numeric move".
>
>  void
>  cob_accept (cob_field *f)
>  {
>    unsigned char data[FILENAME_MAX];
>    cob_field_attr attr = {COB_TYPE_ALPHANUMERIC, 0, 0, 0, 0};
>    cob_field temp = {0, data, &attr};
>
>    /* read data from stdin */
>    fgets (data, FILENAME_MAX, stdin);
>    temp.size = strlen (data) - 1;
>
>    /* move it to the field */
>    cob_move (&temp,

= one possible solution! (= OK!)

The only requirement from me is, that a implementation at this point
should be consistent! (as the implementation above is)

I think such a choice of the implementor should be well documented.
(And the place(s) in the documentation should be easy to find ... )
So,  no users or porters waste time to guess the behavior ! :-)

If i would work in the marketing,  i would call it "tiny-cobol compatible"
 ;-)

If other users need other implementation(s)  they could make feature
 requests. Then, with a appropriate configuration (at compilation-time or
 run-time!) a different behavior would be also fine!

For me that's absolutley sufficing!

> > What do you think about starting a thread
> > in the comp.lang.cobol newsgroup?
>
> I don't read the newsgroup, and I don't want to take too much
> time on this topic.  Just give me an advice how open-cobol
> should work.
>
> Keisuke

Well, other topics are (much) more important!
It's true, the discussion of the standard in the
comp.lang.cobol newsgroup could eat much valuable time!

Thanks

Thomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]