Realized today that when trying to ACCEPT an amount field in GnuCobol 3.12b, that field is always read from the Left to the Right (like a Alphanumeric field).. despite the field being defined as Numeric and/or Numeric Edited.
Microsoft COBOL handled this just fine. Is there a trick to tweaking the compiler options or is this one of those silly things we have to code around?
Thank you,
Steve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In general: a "plain" ACCEPT only works alphanumeric "as keyed into the terminal".
As soon as you get to "extended" screen io (either by including a SCREEN SECTION or by issuing DISPLAY SPACE EOS) GnuCOBOL does some "magic handling".
It is intended to then accept numeric and numeric-edited fields in a reasonable way but even in the newest versions this is something "not fully implemented".
If you only want to use GnuCOBOL - better to "code around" this would be fixing this in GnuCOBOL (libcob/screenio.c) or get someone to do this; if you need your code to be portable to other COBOL environments - accept only PIC X data and adjust this yourself as mentioned in [8e19fd9345] and other posts (search function should help with ways to "code around").
Realized today that when trying to ACCEPT an amount field in GnuCobol
3.12b, that field is always read from the Left to the Right (like a
Alphanumeric field).. despite the field being defined as Numeric
and/or Numeric Edited.
Microsoft COBOL handled this just fine. Is there a trick to tweaking
the compiler options or is this one of those silly things we have to
code around?
Thank you,
Steve
You have to code around it and yes most annoying as MF does it
automatically and has done since CIS Cobol was released in the 70's.
👍
1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Solved.. Coded around it.. Had to switch my screen to PIC X logic and rebuild my numeric fields, as Simon and Bryan alluded. Thanks for the feedback, guys.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Eugenio,
Thank you. Am looking at your coding example and will try that approach as well. Great job documenting. Excellent work. Thanks again, Steve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Eugenio,
Thank you. Am looking at your coding example and will try that
approach as well. Great job documenting. Excellent work. Thanks again,
Steve
Just had a play and it works but when I remove the decimal-point comma
so that period works the example doesn't.
I cannot see why though :(
Vince
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just tried a new variation that seems to work okay. I had coded with SPACES and also had a version that inputted the original numeric fields. That, of course, looked wonky, although it appeared the numbers stored properly.
My latest twist is a simple Display of the Screen field I ACCEPT as Numeric Editied.. and Joila.. it appears as a true number.
What I am describing is a Screen Pic of Z(6)9.99, a using field of S9(07)V99 and an input amount like 123.45
After the ACCEPT the field (without the added DISPLAY) looks like 123 .45 on the screen. With the added DISPLAY of the Screen fields, following the Accept, I see a proper representation of 123.45 on the screen.
Internally, the ACCEPT of numbers as described above, is stored properly in each case.
I see 00001234E
I think I am okay with that.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Slight revision.. Screen field was Z(6).99.. Using the Display after the Accept of the Amount field saved me 35 lines of unnecessary code I had previously installed.. Tested the Add, Inquire and Delete. All good.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a complete working application (a sample "masterfile" management with CRUDE Create, Read, Update and DElete ) using ACCEPT with also NUMERIC fields. See attached screenshot GCCRUDxx.COB
a USER MNUAL GC00TT-MANUAL-V02-20210308.odt, look at page 66.
Realized today that when trying to ACCEPT an amount field in GnuCobol 3.12b, that field is always read from the Left to the Right (like a Alphanumeric field).. despite the field being defined as Numeric and/or Numeric Edited.
Microsoft COBOL handled this just fine. Is there a trick to tweaking the compiler options or is this one of those silly things we have to code around?
Thank you,
Steve
In general: a "plain"
ACCEPT
only works alphanumeric "as keyed into the terminal".As soon as you get to "extended" screen io (either by including a
SCREEN SECTION
or by issuingDISPLAY SPACE EOS
) GnuCOBOL does some "magic handling".It is intended to then accept numeric and numeric-edited fields in a reasonable way but even in the newest versions this is something "not fully implemented".
If you only want to use GnuCOBOL - better to "code around" this would be fixing this in GnuCOBOL (libcob/screenio.c) or get someone to do this; if you need your code to be portable to other COBOL environments - accept only
PIC X
data and adjust this yourself as mentioned in [8e19fd9345] and other posts (search function should help with ways to "code around").Related
Discussion: 8e19fd9345
On 30/09/2021 01:33, Steve Millman wrote:
You have to code around it and yes most annoying as MF does it
automatically and has done since CIS Cobol was released in the 70's.
Solved.. Coded around it.. Had to switch my screen to PIC X logic and rebuild my numeric fields, as Simon and Bryan alluded. Thanks for the feedback, guys.
Please have a look at
3.32 How can I properly manage numeric fields with extended screen IO?
into Brian's FAQ at : https://gnucobol.sourceforge.io/faq/index.html
Hi Eugenio,
Thank you. Am looking at your coding example and will try that approach as well. Great job documenting. Excellent work. Thanks again, Steve
On 01/10/2021 18:20, Steve Millman wrote:
Just had a play and it works but when I remove the decimal-point comma
so that period works the example doesn't.
I cannot see why though :(
Vince
I just tried a new variation that seems to work okay. I had coded with SPACES and also had a version that inputted the original numeric fields. That, of course, looked wonky, although it appeared the numbers stored properly.
My latest twist is a simple Display of the Screen field I ACCEPT as Numeric Editied.. and Joila.. it appears as a true number.
What I am describing is a Screen Pic of Z(6)9.99, a using field of S9(07)V99 and an input amount like 123.45
After the ACCEPT the field (without the added DISPLAY) looks like 123 .45 on the screen. With the added DISPLAY of the Screen fields, following the Accept, I see a proper representation of 123.45 on the screen.
Internally, the ACCEPT of numbers as described above, is stored properly in each case.
I see 00001234E
I think I am okay with that.
Slight revision.. Screen field was Z(6).99.. Using the Display after the Accept of the Amount field saved me 35 lines of unnecessary code I had previously installed.. Tested the Add, Inquire and Delete. All good.
other similar stuff at
https://sourceforge.net/p/gnucobol/discussion/help/thread/9deac5a3/?limit=50#0878
At https://sourceforge.net/p/gnucobol/contrib/HEAD/tree/trunk/tools/TUI-TOOLS/ you will find