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

    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
                          • 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

                            M Offline
                            M Offline
                            Mark_Wallace
                            wrote on last edited by
                            #34

                            PIC simply sets the output type. PIC X is alphanumeric, and PIC 9 is numeric, so PIC X(2816) is 2816 alphanumeric characters (in this case used to reserve contiguous space -- a common trick in COBOL, where you're not supposed to worry about things like memory allocation), and PIC 9(4) is four numeric digits.

                            I wanna be a eunuchs developer! Pass me a bread knife!

                            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

                              T Offline
                              T Offline
                              the SPOF
                              wrote on last edited by
                              #35

                              01 MEMORY-AREA-ONE PIC X(2816) Declares a variable of 2816 chars, same as C char[2816]. The REDEFINE statement means that the next structure will occupy the same physical memory as MEMORY-AREA-ONE - much like a C UNION. Each 'PIC 9(04) COMP' is a 4 byte numeric optimised for computation, this is the same as a C UINT. If 'COMP' had been ommitted then the each of these variables would be able to store anything from 0 to 9999 and these would be stored as ASCII numeric digits which isnt efficient for computation but is how COBOL was designed to be used by 'non programmers' who didnt need to understand computer internals. This structure is typically used for low level data manipulation like encryption or compression because its the only way you could have a sequence of numbers and be able to address bytes at any offset within a structure - the char[2816] is effectively used as a char*. OCCURS is just an array count. Hope that answers your questions.

                              1 Reply Last reply
                              0
                              • S Sean Cundiff

                                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 Offline
                                T Offline
                                tonosuk
                                wrote on last edited by
                                #36

                                From my COBOL days numerous years ago, then comp-5 was machine dependant, so on an intel 8086 would be stored in reverse binary and wouldn't require the bit swapping by the compiler that defining as 'comp' would require. I remember a comp-x format too that was machine independant. We would also define a pic 9(04) comp-5 fields as pic x(02) comp-5 to make it more obvious that the field took 2 bytes of storage. That was based on Micro Focus compilers with syntax targetted at pc-only runtime environment where writing presentation manager apps in COBOL was the last word in chic and guaranteed many a dinner party invitation! I seem to remember that the indexed by declaration came in useful during iterations or using the Search verb, maybe, perhaps. Tony

                                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

                                  R Offline
                                  R Offline
                                  redware
                                  wrote on last edited by
                                  #37

                                  Not a COBOL programmer, but here goes nothing: Comp-5 is a "native" binary format. Equivalent of "comp" type. pic 9(4) comp-5 is a two-byte unsigned binary 0 - 65535. Roughly in 'C, you are looking at: union { unsigned char buffer[2816] ; struct { unsigned short k01[37] ; unsigned short k02[1369]; } a ; } mem_area_one ; The layout of the two-bytes is platform specific ("native"), so if the COBOL is running on a PC platform, the two-bytes are stored in memory reversed (value of 12 decimal is stored as 0x0c00 in byte order).

                                  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

                                    N Offline
                                    N Offline
                                    Norm Powroz
                                    wrote on last edited by
                                    #38

                                    As previously pointed out, MEMORY-AREA-ONE is a string of 2816 characters [PIC X(...) is the method by which character data is reserved/declared, and space assigned for it]. The REDEFINES... is a common COBOL method for permitting memory/data to be accessed in multiple ways. The C/C++ equivalent would be a "struct" definition with a "union" component -- you can access the memory using either elements of the struct, or elements of the union. Most "COMP-xx" data definitions are implementor-defined, so you will need the specific COBOL documentation for the machine upon which this code was implemented. IBM was a big user of COMP-xx declarations, and had several flavours of them, so you could have true floating-point, or packed-decimal data in a COBOL program by using their COMP-xx datatypes. Without the specific documentation, it is impossible to say exactly how the redefined data mask would lay out over the original character space. These kinds of implementor-defined situations always made conversions from one mainframe machine architecture to another somewhat interesting. The INDEXED BY clauses instruct the compiler to reserve specific indexes for iterating through the array created by the OCCURS clause. The assignment of an index usually translated (at the machine hardware level) into the use of a reserved index register. This was done for performance, rather than using a memory-based byte/word for storage of the array index value. As such, you don't need to be too worried about the INDEXED BY clause, as it's more a compiler instruction than anything else. Hope this helps. Norm Powroz Former member, CODASYL COBOL Committee (the people who designed the language) Former Member, ISO COBOL Experts Group Former Member, CSA COBOL Working Group ...and I'm not retired yet ;)

                                    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

                                      T Offline
                                      T Offline
                                      tam462
                                      wrote on last edited by
                                      #39

                                      COBOL pre-allocates memory for everything in the code at runtime. All variables used are created in the WORKING STORAGE section. Nothing is dynamically created or destroyed in a garbage collection sweep. PIC X is a byte of memory, so PIC X(2816) is a block of memory taking 2816 bytes. By default, "PIC" will use the translation base of the machine, e.g. EBCDIC on a mainframe or ASCII on most anything else. "COMP" data types are a way to pack numeric values into a smaller number of bytes, much like INT and FLOAT. PIC 9 is a numeric data type. PIC 9(4) uses 4 bytes of memory to contain the number. PIC 9(4) COMP-5 in particular is a 32-bit signed float. "OCCURS" is used to create an array. "INDEXED BY" also creates the index to the array at the same time. "REDEFINES" means "uses the same memory space as". Putting it all together: 01 MEMORY-AREA-ONE is simply a block of memory using 2816 bytes. Inside that block of memory, there are two float arrays, one called K01-1 with 37 elements, and the other called K02-1 with 1369 element. To reference a given element in an array, you first assign a value to the index, then you can get what you need from the array. e.g. "MOVE 1 TO KO1-1-X." followed by "ADD K01-1 (KO1-1-X) TO TOTAL." I don't know why you use a REDEFINES for a bunch of floats, unless you needed to dump all of them to an output file for some reason, then it's only 1 line of code, rather than writing the loop logic. (I'm a 2nd-gen coder. The old man taught me this stuff when I was 14. His lab classes when he was in school were "paper-tape in, oscilloscope out" and they programmed in binary. He used to quote "Assembler was a godsend." I'm attending the VS 2010 launch in 15 minutes.) Good luck.

                                      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

                                        N Offline
                                        N Offline
                                        ntrceptr
                                        wrote on last edited by
                                        #40

                                        Dougs' replay was the closest thing to correct so far. 01 MEMORY-AREA-ONE PIC X(2816). This just defines a 2816 byte vaariable and the PIC X means it's alphanumeric 01 REDEFINES MEMORY-AREA-ONE This says your going to redefine that chunk of data into a different structure/layout 05 K01-1 OCCURS 37 TIMES INDEXED BY K01-1-X PIC 9(04) COMP-5. These 2 lines make an array of 37 four digit numbers (0000-9999) and gives you a subscript named K01-1-X to reference entries 1-37 remember COBOL subscripts start at 1 not zero. This K01-1 array actually exists in the first 74 bytes of MEMORY-AREA-ONE The COMP-5 or any COMP in COBOL basicall says to save space by representing the numbers in memory (like they should) in a binary format. COBOL will basically use a string for numbers is you don't use COMP (1 byte for each digit) 05 K02-1 OCCURS 1369 TIMES INDEXED BY K02-1-X PIC 9(04) COMP-5. This is basically the same except it uses bytes 75-2812 of MEMORY-AREA-ONE to define and array of 1369 four digit numbers and gives you subscript K02-1-X to reference it. I'd say the original author didn't quite understand COBOL either as you dont need to define extra space in the MEMORY-AREA-ONE for the subscripts. if it was 01 MEMORY-AREA-ONE PIC X(2812) it would have worked the same.

                                        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

                                          P Offline
                                          P Offline
                                          pimpaler
                                          wrote on last edited by
                                          #41

                                          This does not appear like a valid definition. Since "9(04) COMP-5" represents a 2-byte integer number and (37 + 1369) * 2 = 2812 and not 2816, you are certainly missing some further variable definitions or the COBOL program itself does not compile (or, if it does, it is not a very well made program). "INDEXED BY" just means that the tables defined by names K01-1 and K02-1 can be searched for values using built-in SEARCH function(s).

                                          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