Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Remember COBOL ?!

  • 04-08-2004 11:00pm
    #1
    Registered Users, Registered Users 2 Posts: 6,163 ✭✭✭


    Does anyone here speak COBOL. It's an ancient language from a far off time that doesn't appear to understand decimel numbers!!

    I'm using MicroFocus Personal Cobol V3.11 for Windows 95 on a Win 98 machine. I seems to run fine except that I cant get decimel points to show up. For example:

    SUM-NUM PIC X(5) VALUE "12.567".

    Will display:

    12.567

    the decimel point present, but:

    SUM-NUM PIC Z9V999 VALUE 12.567.

    DISPLAY "The number is: "SUM-NUM.

    Returns 12567 !!

    Am I doing something daft ?
    I have ACUCOBOL GT and it works fine, why won't this.

    Regards

    ZEN


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    Shouldn't it be..

    ZZ.999 ? or 99V999


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    I think you should have
    SUM-NUM PIC Z9V999 VALUE 12567.

    No decimal point in the VALUE as the V in the PIC puts it in for you. Numbers can only contain numbers no fancy things like decimal points :-)

    I'm not overly certain of this however.
    Best of luck.
    A.


  • Registered Users, Registered Users 2 Posts: 1,423 ✭✭✭Merrion


    The V indicates an implied decimal point.
    This is used to allow you to do integer maths with decimals - kind of thing that happens a lot in financial calculations which is what COBOL was designed for (and is good at).


  • Registered Users, Registered Users 2 Posts: 14,149 ✭✭✭✭Lemming


    Hobbes wrote:
    Shouldn't it be..

    ZZ.999 ? or 99V999

    iirc from my college days (and I don't particularly want to given that this is COBOL that we're talking about), isn't it 99v999? :confused:

    COBOL; Completely Obsolete Business Oriented Language



    PCMCIA; People Can't Memorise Computer Industry Acrynoms

    *drum crash* Thank you folks! I'm here all week!


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    99V999 or Z9V999 or ZZV999 are fine.

    Z suppresses zeroes, iirc

    Some examples
    PIC 99V999 VALUE 2345 Ouputs 02.345
    PIC Z9V999 VALUE 2345 Ouputs 2.345
    PIC ZZV999 VALUE 0345 Ouputs .345
    PIC ZZV999 VALUE 345 Ouputs .345

    <edit>just checked and all of the above are correct</edit>

    A.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,163 ✭✭✭ZENER


    I'd never have believed that so many of you knew about COBOL !!

    Any way I got it figured out. Internal numbers with decimel points are stored:

    01 ANY-NUMBER PIC ZZ9V99 VALUE = .94

    RESULT 094 <-- THE "." IS "IMPLIED"

    IN ORDER TO DISPLAY A NUMBER WITH A "." :

    01 DISPLAY-RESULT PIC ZZ9.99

    OR IF YOU DEFINE A CURRENCY

    01 DISPLAY-RESULT PIC €€9.99

    So if ANY-NUMBER (e.g. 13.67) is MOVED to DISPLAY-RESULT and
    ANY-NUMBER then:

    DISPLAY DISPLAY-RESULT.
    DISPLAY ANY-NUMBER.

    Would return:

    €13.67
    01367

    Seems numbers with "." cannot be used in calculations as said above.

    Thanks All !

    ZEN


  • Closed Accounts Posts: 22 Armen Tanzerian


    Something like 70% of the world's data is wrapped in COBOL. I'd say it's fairly decent at understanding decimal numbers. :D I have worked at it for the last 15 years in the States. For a lazy person like myself it's a great language, never changes. The systems programmers use the new functions, which are actually quite impressive, but application programmers do what they've always done. No refresher courses for me. :cool:


  • Registered Users, Registered Users 2 Posts: 6,163 ✭✭✭ZENER


    When I was told I'd be using COBOL for my assignments I thought it was a bit out-dated, seems I'm well wide of the mark though. It's easy to follow compared to something like Java but then I suppose their objectives are different.

    Thanks again for the info lads - it's all been filed under E for Experience !

    ZEN


Advertisement