Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Gods Of COBOL

Gods Of COBOL

Scheduled Pinned Locked Moved The Lounge
comperformancequestion
61 Posts 40 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Chris Losinger

    anybody here know COBOL ? what does this do?

       01 MEMORY-AREA-ONE                           PIC X(2816).
    
       01  REDEFINES MEMORY-AREA-ONE.          
          05 K01-1 OCCURS 37 TIMES             
                   INDEXED BY K01-1-X               PIC 9(04) COMP-5.
          05 K02-1 OCCURS 1369 TIMES           
                   INDEXED BY K02-1-X               PIC 9(04) COMP-5.
    

    i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

    image processing toolkits | batch image processing

    D Offline
    D Offline
    Douglas Troy
    wrote on last edited by
    #14

    This is nothing more than a string (alphanumeric) 2816 characters

    Chris Losinger wrote:

    01 MEMORY-AREA-ONE PIC X(2816).

    that second section

    Chris Losinger wrote:

    01 REDEFINES MEMORY-AREA-ONE. 05 K01-1 OCCURS 37 TIMES INDEXED BY K01-1-X PIC 9(04) COMP-5. 05 K02-1 OCCURS 1369 TIMES INDEXED BY K02-1-X PIC 9(04) COMP-5.

    Pic 9(04) COMP-5 is a 4 byte numeric stored in machine independent format Essentially, those two lines redefine the space originally defined by MEMORY-AREA-ONE into two blocks of unsigned 16-bit integers. I cannot recall what the INDEXED allows you to do anymore ... Not sure any of that helps you ... [edit] You might also considering hitting up the COBOL User Groups[^] for help with this, and/or other COBOL related issues you might have. Just a thought.


    :..::. Douglas H. Troy ::..
    Bad Astronomy |VCF|wxWidgets|WTL

    modified on Friday, April 9, 2010 5:51 PM

    C S N A 4 Replies Last reply
    0
    • C Chris Losinger

      anybody here know COBOL ? what does this do?

         01 MEMORY-AREA-ONE                           PIC X(2816).
      
         01  REDEFINES MEMORY-AREA-ONE.          
            05 K01-1 OCCURS 37 TIMES             
                     INDEXED BY K01-1-X               PIC 9(04) COMP-5.
            05 K02-1 OCCURS 1369 TIMES           
                     INDEXED BY K02-1-X               PIC 9(04) COMP-5.
      

      i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

      image processing toolkits | batch image processing

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #15

      Hi Chris, you are aware there are a couple of .NET COBOL compilers around? you might be lucky and have a look at the IL your source generates; and reflector might be willing to show you equivalent C# or VB.NET code. And maybe you don't need to translate it after all, just run it... :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Getting an article published on CodeProject should be easier and faster for Bronze and Silver authors.


      C C 2 Replies Last reply
      0
      • C Chris Losinger

        anybody here know COBOL ? what does this do?

           01 MEMORY-AREA-ONE                           PIC X(2816).
        
           01  REDEFINES MEMORY-AREA-ONE.          
              05 K01-1 OCCURS 37 TIMES             
                       INDEXED BY K01-1-X               PIC 9(04) COMP-5.
              05 K02-1 OCCURS 1369 TIMES           
                       INDEXED BY K02-1-X               PIC 9(04) COMP-5.
        

        i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

        image processing toolkits | batch image processing

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #16

        No cookie for you: COBOL is the only computer language invented by the Etrurians. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        1 Reply Last reply
        0
        • L Luc Pattyn

          Hi Chris, you are aware there are a couple of .NET COBOL compilers around? you might be lucky and have a look at the IL your source generates; and reflector might be willing to show you equivalent C# or VB.NET code. And maybe you don't need to translate it after all, just run it... :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Getting an article published on CodeProject should be easier and faster for Bronze and Silver authors.


          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #17

          Luc Pattyn wrote:

          you are aware there are a couple of .NET COBOL compilers around?

          Their authors should be flamed, immediately. :rolleyes:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          1 Reply Last reply
          0
          • C Chris Losinger

            anybody here know COBOL ? what does this do?

               01 MEMORY-AREA-ONE                           PIC X(2816).
            
               01  REDEFINES MEMORY-AREA-ONE.          
                  05 K01-1 OCCURS 37 TIMES             
                           INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                  05 K02-1 OCCURS 1369 TIMES           
                           INDEXED BY K02-1-X               PIC 9(04) COMP-5.
            

            i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

            image processing toolkits | batch image processing

            S Offline
            S Offline
            Steve Mayfield
            wrote on last edited by
            #18

            Isn't that part of the start up code for Cylons...oh wait, that's "Lords of Kobol" :laugh:

            Steve _________________ I C(++) therefore I am

            modified on Friday, April 9, 2010 5:55 PM

            1 Reply Last reply
            0
            • C Chris Losinger

              anybody here know COBOL ? what does this do?

                 01 MEMORY-AREA-ONE                           PIC X(2816).
              
                 01  REDEFINES MEMORY-AREA-ONE.          
                    05 K01-1 OCCURS 37 TIMES             
                             INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                    05 K02-1 OCCURS 1369 TIMES           
                             INDEXED BY K02-1-X               PIC 9(04) COMP-5.
              

              i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

              image processing toolkits | batch image processing

              M Offline
              M Offline
              martin_hughes
              wrote on last edited by
              #19
               01 SORRY-CHRIS                                          PIC YOUR-NAME(LANCELOT).
               
               01 I-DON'T-KNOW.
                 05 IDK OCCURS 100 TIMES
                        INDEXED BY I-REALLY-DON'T-KNOW                 PIC A-COLOUR(BLUE).
                 05 IDK-2 OCCURS 1520 TIMES
                        INDEXED BY WHAT-IS-THE-CAPITAL-OF-ASSYRIA      I-DON'T-KNOW-THAT(NONE).  
              

              Output is apparently "Arrrrrrrrrrrrrggggggggggghhhhhhhhhhhhhhhhhh!"

              Books written by CP members

              C 1 Reply Last reply
              0
              • C Chris Losinger

                Andy Brummer wrote:

                a bunch of 2 byte integers with 4 bytes left over

                hmm... yeah, i suppose that could be it. the 'leftover bytes' feels stupid and wrong, but maybe i should just get over that... i'll give it a try!

                image processing toolkits | batch image processing

                modified on Friday, April 9, 2010 4:38 PM

                S Offline
                S Offline
                Steve Mayfield
                wrote on last edited by
                #20

                4 bytes left over Maybe the 4 extra bytes are for the array index variables (K01-1-X & K02-1-X)

                Steve _________________ I C(++) therefore I am

                1 Reply Last reply
                0
                • C Chris Losinger

                  anybody here know COBOL ? what does this do?

                     01 MEMORY-AREA-ONE                           PIC X(2816).
                  
                     01  REDEFINES MEMORY-AREA-ONE.          
                        05 K01-1 OCCURS 37 TIMES             
                                 INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                        05 K02-1 OCCURS 1369 TIMES           
                                 INDEXED BY K02-1-X               PIC 9(04) COMP-5.
                  

                  i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

                  image processing toolkits | batch image processing

                  S Offline
                  S Offline
                  Steve Mayfield
                  wrote on last edited by
                  #21

                  01 MEMORY-AREA-ONE PIC X(2816).
                  01 REDEFINES MEMORY-AREA-ONE.
                  05 K01-1 OCCURS 37 TIMES
                  INDEXED BY K01-1-X PIC 9(04) COMP-5.
                  05 K02-1 OCCURS 1369 TIMES
                  INDEXED BY K02-1-X PIC 9(04) COMP-5.

                  maybe becomes :confused:

                  union {
                  {
                  PIC MEMORY-AREA-ONE X[2816];
                  struct {
                  PIC K01-1-X;
                  PIC K01-1[37];
                  PIC K02-1-X;
                  PIC K02-1[1369];
                  } COMP-5
                  };

                  Steve _________________ I C(++) therefore I am

                  1 Reply Last reply
                  0
                  • C Chris Losinger

                    Andy Brummer wrote:

                    a bunch of 2 byte integers with 4 bytes left over

                    hmm... yeah, i suppose that could be it. the 'leftover bytes' feels stupid and wrong, but maybe i should just get over that... i'll give it a try!

                    image processing toolkits | batch image processing

                    modified on Friday, April 9, 2010 4:38 PM

                    J Offline
                    J Offline
                    JimmyRopes
                    wrote on last edited by
                    #22

                    Chris Losinger wrote:

                    'leftover bytes' feels stupid

                    COBOL programmers were never known to be sticklers for programming best practices. COBOL, like VB, allows non-programmers to think they can program. I have many years of experience in technical support (we programmed in assembler on IBM mainframes) supporting COBOL shops, and I have the scars to prove it.

                    Simply Elegant Designs JimmyRopes Designs
                    Think inside the box! ProActive Secure Systems
                    I'm on-line therefore I am. JimmyRopes

                    1 Reply Last reply
                    0
                    • D Douglas Troy

                      This is nothing more than a string (alphanumeric) 2816 characters

                      Chris Losinger wrote:

                      01 MEMORY-AREA-ONE PIC X(2816).

                      that second section

                      Chris Losinger wrote:

                      01 REDEFINES MEMORY-AREA-ONE. 05 K01-1 OCCURS 37 TIMES INDEXED BY K01-1-X PIC 9(04) COMP-5. 05 K02-1 OCCURS 1369 TIMES INDEXED BY K02-1-X PIC 9(04) COMP-5.

                      Pic 9(04) COMP-5 is a 4 byte numeric stored in machine independent format Essentially, those two lines redefine the space originally defined by MEMORY-AREA-ONE into two blocks of unsigned 16-bit integers. I cannot recall what the INDEXED allows you to do anymore ... Not sure any of that helps you ... [edit] You might also considering hitting up the COBOL User Groups[^] for help with this, and/or other COBOL related issues you might have. Just a thought.


                      :..::. Douglas H. Troy ::..
                      Bad Astronomy |VCF|wxWidgets|WTL

                      modified on Friday, April 9, 2010 5:51 PM

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #23

                      Douglas Troy wrote:

                      I cannot recall what the INDEXED allows you to do anymore ..

                      i think that defines an iterator/pointer that's initialized to the start of the subgroup.

                      image processing toolkits | batch image processing

                      1 Reply Last reply
                      0
                      • C Chris Losinger

                        anybody here know COBOL ? what does this do?

                           01 MEMORY-AREA-ONE                           PIC X(2816).
                        
                           01  REDEFINES MEMORY-AREA-ONE.          
                              05 K01-1 OCCURS 37 TIMES             
                                       INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                              05 K02-1 OCCURS 1369 TIMES           
                                       INDEXED BY K02-1-X               PIC 9(04) COMP-5.
                        

                        i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

                        image processing toolkits | batch image processing

                        S Offline
                        S Offline
                        Sean Cundiff
                        wrote on last edited by
                        #24

                        Chris Losinger wrote:

                        01 MEMORY-AREA-ONE PIC X(2816).

                        Allocate a block of memory 2816 bytes in size and fill with 'X'. Name the block of memory 'MEMORY-AREA-ONE'.

                        Chris Losinger wrote:

                        01 REDEFINES MEMORY-AREA-ONE.
                        05 K01-1 OCCURS 37 TIMES
                        INDEXED BY K01-1-X PIC 9(04) COMP-5.
                        05 K02-1 OCCURS 1369 TIMES
                        INDEXED BY K02-1-X PIC 9(04) COMP-5.

                        Reallocate the array for a different purpose. K01-1 is an array that contains 37 elements. The index to the array is K01-1-X. Each element is a 4-byte numeric. 'PIC 9(04)' Each element is stored as a 2's complement big-endian number in machine-dependant format. 'COMP-5' When I say big-endian I mean that when the number is displayed it will be displayed as 4 digits from left to right with most significant to least significant order. Whether it's big-endian in memory depends on the implementation. K02-1 is a 1369 element array with similar properties. K01-1-X and K02-1-X are the variables used to index the arrays. Each one belongs to it's respective array and can't be used for the other one. p-code example: for K01-1-X in {1 .. 37} do something with K01-1[K01-1-X]

                        -Sean ---- Fire Nuts

                        modified on Friday, April 9, 2010 6:58 PM

                        C M 2 Replies Last reply
                        0
                        • D Douglas Troy

                          This is nothing more than a string (alphanumeric) 2816 characters

                          Chris Losinger wrote:

                          01 MEMORY-AREA-ONE PIC X(2816).

                          that second section

                          Chris Losinger wrote:

                          01 REDEFINES MEMORY-AREA-ONE. 05 K01-1 OCCURS 37 TIMES INDEXED BY K01-1-X PIC 9(04) COMP-5. 05 K02-1 OCCURS 1369 TIMES INDEXED BY K02-1-X PIC 9(04) COMP-5.

                          Pic 9(04) COMP-5 is a 4 byte numeric stored in machine independent format Essentially, those two lines redefine the space originally defined by MEMORY-AREA-ONE into two blocks of unsigned 16-bit integers. I cannot recall what the INDEXED allows you to do anymore ... Not sure any of that helps you ... [edit] You might also considering hitting up the COBOL User Groups[^] for help with this, and/or other COBOL related issues you might have. Just a thought.


                          :..::. Douglas H. Troy ::..
                          Bad Astronomy |VCF|wxWidgets|WTL

                          modified on Friday, April 9, 2010 5:51 PM

                          S Offline
                          S Offline
                          Sean Cundiff
                          wrote on last edited by
                          #25

                          Douglas Troy wrote:

                          Pic 9(04) COMP-5 is a 4 byte numeric stored in machine independent format

                          Machine-dependent format if I'm not mistaken. COMP-4 is machine independent.

                          -Sean ---- Fire Nuts

                          T A 2 Replies Last reply
                          0
                          • S Sean Cundiff

                            Chris Losinger wrote:

                            01 MEMORY-AREA-ONE PIC X(2816).

                            Allocate a block of memory 2816 bytes in size and fill with 'X'. Name the block of memory 'MEMORY-AREA-ONE'.

                            Chris Losinger wrote:

                            01 REDEFINES MEMORY-AREA-ONE.
                            05 K01-1 OCCURS 37 TIMES
                            INDEXED BY K01-1-X PIC 9(04) COMP-5.
                            05 K02-1 OCCURS 1369 TIMES
                            INDEXED BY K02-1-X PIC 9(04) COMP-5.

                            Reallocate the array for a different purpose. K01-1 is an array that contains 37 elements. The index to the array is K01-1-X. Each element is a 4-byte numeric. 'PIC 9(04)' Each element is stored as a 2's complement big-endian number in machine-dependant format. 'COMP-5' When I say big-endian I mean that when the number is displayed it will be displayed as 4 digits from left to right with most significant to least significant order. Whether it's big-endian in memory depends on the implementation. K02-1 is a 1369 element array with similar properties. K01-1-X and K02-1-X are the variables used to index the arrays. Each one belongs to it's respective array and can't be used for the other one. p-code example: for K01-1-X in {1 .. 37} do something with K01-1[K01-1-X]

                            -Sean ---- Fire Nuts

                            modified on Friday, April 9, 2010 6:58 PM

                            C Offline
                            C Offline
                            Chris Losinger
                            wrote on last edited by
                            #26

                            how can they be 4 byte integers ? that's twice the size of the MEMORY-AREA-ONE's 2816 bytes. (37 + 1369) * 4 = 5624 i'm thinking the 4 is the number of places allowed for the value. 9(4) is a 4 digit integer (0-9999) ? you can fit that in a two byte integer, which would fit in the 2816 bytes. make sense ?

                            image processing toolkits | batch image processing

                            S 1 Reply Last reply
                            0
                            • C Chris Losinger

                              how can they be 4 byte integers ? that's twice the size of the MEMORY-AREA-ONE's 2816 bytes. (37 + 1369) * 4 = 5624 i'm thinking the 4 is the number of places allowed for the value. 9(4) is a 4 digit integer (0-9999) ? you can fit that in a two byte integer, which would fit in the 2816 bytes. make sense ?

                              image processing toolkits | batch image processing

                              S Offline
                              S Offline
                              Sean Cundiff
                              wrote on last edited by
                              #27

                              yeah I updated my post after I realized I put the wrong info in it. 4 byte 'numeric'. the numeric is stored in memory as a 2's complement number, big-endian and machine-dependent format. So 37 * 2 + 2 for the first array, and 1369 * 2 + 2 for the second array. ==> 76 + 2740 = 2816 bytes.

                              -Sean ---- Fire Nuts

                              1 Reply Last reply
                              0
                              • C Chris Losinger

                                anybody here know COBOL ? what does this do?

                                   01 MEMORY-AREA-ONE                           PIC X(2816).
                                
                                   01  REDEFINES MEMORY-AREA-ONE.          
                                      05 K01-1 OCCURS 37 TIMES             
                                               INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                                      05 K02-1 OCCURS 1369 TIMES           
                                               INDEXED BY K02-1-X               PIC 9(04) COMP-5.
                                

                                i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

                                image processing toolkits | batch image processing

                                D Offline
                                D Offline
                                Dan Mos
                                wrote on last edited by
                                #28

                                It throws an exception!! Either a System_TerrorException or a System_LiquidNitro one.

                                A 1 Reply Last reply
                                0
                                • D Dan Mos

                                  It throws an exception!! Either a System_TerrorException or a System_LiquidNitro one.

                                  A Offline
                                  A Offline
                                  AspDotNetDev
                                  wrote on last edited by
                                  #29

                                  Or a Dumber_Than_Baboon_Exception.

                                  [Forum Guidelines]

                                  D 1 Reply Last reply
                                  0
                                  • A AspDotNetDev

                                    Or a Dumber_Than_Baboon_Exception.

                                    [Forum Guidelines]

                                    D Offline
                                    D Offline
                                    Dan Mos
                                    wrote on last edited by
                                    #30

                                    My bad. I totally forgat about it. Forgime me pls!!! URGENT!!!

                                    1 Reply Last reply
                                    0
                                    • C Chris Losinger

                                      anybody here know COBOL ? what does this do?

                                         01 MEMORY-AREA-ONE                           PIC X(2816).
                                      
                                         01  REDEFINES MEMORY-AREA-ONE.          
                                            05 K01-1 OCCURS 37 TIMES             
                                                     INDEXED BY K01-1-X               PIC 9(04) COMP-5.
                                            05 K02-1 OCCURS 1369 TIMES           
                                                     INDEXED BY K02-1-X               PIC 9(04) COMP-5.
                                      

                                      i thought i understood what redefine and occurs meant, but i can't figure out what this declaration does. (funny answers are welcome!)

                                      image processing toolkits | batch image processing

                                      B Offline
                                      B Offline
                                      BonshatS
                                      wrote on last edited by
                                      #31

                                      I knew cobol in another long ago and far away life.

                                      01 MEMORY-AREA-ONE PIC X(2816).

                                      01 REDEFINES MEMORY-AREA-ONE.
                                      05 K01-1 OCCURS 37 TIMES
                                      INDEXED BY K01-1-X PIC 9(04) COMP-5.
                                      05 K02-1 OCCURS 1369 TIMES
                                      INDEXED BY K02-1-X PIC 9(04) COMP-5.

                                      If I remember right, that corresponds to :

                                      struct numeric_arrays
                                      {
                                      short k01_1_x;
                                      short k01_1[37];
                                      short k02_1_x;
                                      short k02_1[1369];
                                      };

                                      union mem_area
                                      {
                                      char memory_area_one[2816];
                                      numeric_arrays k01_and_k02;
                                      };

                                      As others have said, the PIC 9(04) is 4 numeric digits and the comp-5 packs it to 2 bytes. I believe the indices map to mem preceding the array parts in mem, but I'm not 100% sure.

                                      1 Reply Last reply
                                      0
                                      • M martin_hughes
                                         01 SORRY-CHRIS                                          PIC YOUR-NAME(LANCELOT).
                                         
                                         01 I-DON'T-KNOW.
                                           05 IDK OCCURS 100 TIMES
                                                  INDEXED BY I-REALLY-DON'T-KNOW                 PIC A-COLOUR(BLUE).
                                           05 IDK-2 OCCURS 1520 TIMES
                                                  INDEXED BY WHAT-IS-THE-CAPITAL-OF-ASSYRIA      I-DON'T-KNOW-THAT(NONE).  
                                        

                                        Output is apparently "Arrrrrrrrrrrrrggggggggggghhhhhhhhhhhhhhhhhh!"

                                        Books written by CP members

                                        C Offline
                                        C Offline
                                        chrissb
                                        wrote on last edited by
                                        #32

                                        Hahaha. Excellent dude. Best Holy Grail reference I've seen yet.

                                        1 Reply Last reply
                                        0
                                        • X Xiangyang Liu

                                          You may want to call AARP[^], I am pretty sure 90% of cobol programmers are members. :)

                                          My .NET Business Application Framework     My Younger Son & His "PET"

                                          H Offline
                                          H Offline
                                          Hired Mind
                                          wrote on last edited by
                                          #33

                                          HAHA! Funny you should say that - I just took a job to completely re-write a suite of COBOL programs in .Net that run every aspect of a utility company. And the reason they hired me? Their COBOL programmer just retired. (Thankfully he's on retainer as a consultant) To the OP: Sorry - I know very little COBOL, but if you ask again in a couple months I could probably help :)

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups