Gods Of COBOL
-
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]
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] -
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!)
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
-
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!)
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!"
-
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
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
-
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!)
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
-
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
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 -
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|WTLmodified on Friday, April 9, 2010 5:51 PM
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.
-
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!)
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
-
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|WTLmodified on Friday, April 9, 2010 5:51 PM
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
-
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
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 ?
-
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 ?
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
-
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!)
-
Or a
Dumber_Than_
Baboon_Exception
. -
Or a
Dumber_Than_
Baboon_Exception
. -
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!)
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.
-
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!"
-
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"
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 :)
-
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
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!
-
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!)
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.
-
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
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