Re: COBOL is dynamic (depends)



Frank Swarbrick wrote:
Richard<riplin@xxxxxxxxxxxx> 10/26/06 5:32 PM >>>

HeyBub wrote:

Your solution is simple, compact, and easy to understand.

You're lucky to have a compiler that permits field names after an
ODO. For those of us with conforming compilers, your solution can't
be used. If faced with the same problem, I'd have to march an index
down the input record moving individual bytes to their prescribed
destinations.

Or use reference notation, perhaps table driven:

01 Tspec PIC X(36) VALUE
"001004005002007049056004060049109001".
01 Uspec PIC X(36) VALUE
"001004005002007033040004044033077001".
etc
01 FieldSpec.
03 AStart PIC 999.
03 ALen PIC 999.
03 BStart PIC 999.
03 BLen PIC 999.
etc

MOVE TSpec TO FieldSpec
EVALUATE Data-In(CStart:1)
WHEN "U"
MOVE Uspec TO FieldSpec
WHEN OTHER
etc

MOVE Data-In(AStart:ALen) TO A
MOVE Data-In(BStart:BLen) TO B
etc

I think you'll have to admit that you can't just glance at that and
see what it is actually doing, while my original example is probably
readible even by a non-programmer.

What I like about my original example is that it does what computers
are made to do; the hard stuff. It leaves the programmer to do his
job rather that trying to figure out how to get the computer to do
the computer's job.

Frank


As I said originally, your solution is, indeed, elegant. For those without
your compiler's abilities, we are constrained to less forthright solutions,
such as the one Richard demonstrated.

I, personally, would attack the problem thusly:

....
READ Input-File
CALL 'DECOMPOSE' USING Input-File Restultant-Fields
....

Then nobody would know how convoluted the code might be.


.