Re: Right justifying (arbitrary) alphanumeric input

From: Chuck Stevens (charles.stevens_at_unisys.com)
Date: 03/02/05


Date: Wed, 2 Mar 2005 13:53:52 -0800

Well, hmm. What comes to mind is the comment of a dyed-in-the-wool Jaguar
fanatic back in the 1950's when describing Mercedes-Benz engineering
techniques: "A maximally-complicated solution to a minimal problem."
;-) Abuse of "function reverse", indeed!

    -Chuck Stevens

<epc8@juno.com> wrote in message
news:1109799364.993754.281280@l41g2000cwc.googlegroups.com...
>
> Chuck Stevens wrote:
> > <epc8@juno.com> wrote in message
> > news:1109776059.651885.302910@l41g2000cwc.googlegroups.com...
> >
> > > Here's an interesting way to abuse function reverse. ...
> >
> > I tried to compile your program and ran into some problems:
> >
> > ANSI X3.23-1985 page VI-27, 5.8.3, the OCCURS clause, syntax rule 7:
> "A
> > data description entry that contains format 2 of the OCCURS clause
> may only
> > e followed, within that record description, by data description
> entries
> > which are subordinate to it. Ibid., page VI-38, 5.10.3, the
> REDEFINES
> > clause, syntax rule 5: "Neither the original definition nor the
> > redefinition can include a variable occurrence data item." Note also
> that
> > the definition of the COBOL character set on page III-3 includes the
> > quotation mark (") but not the apostrophe (').
> >
> > ISO/IEC 1989:2002 page 307, 13.16.36.2, OCCURS clause, syntax rule
> 20: "The
> > subject of the entry may be followed within that record description
> entry
> > only by data description entries that are subordinate to it.".
> Ibid., page
> > 336, 13.16.42.2, REDEFINES clause, syntax rule 6: "Neither the
> original
> > definition nor the redefinition shall include a variable-occurrence
> data
> > item." Note that the 2002 standard adds the apostrophe and the
> underscore
> > to the COBOL character repertoire.
> >
> > I'd say this program abuses rather more than the REVERSE intrinsic
> function!
> > Could you maybe show a program that illustrates your point that
> doesn't
> > violate COBOL standards? ;-)
> >
> > -Chuck Stevens
>
> Thanks. I have since learned that expressions are allowed in reference
> modificaion, once I separate the operators from the operands. So the
> program simplifies to this:
>
> identification division.
> program-id. test1.
> data division.
> working-storage section.
> 01 x pic x(26) value "abcdefghijklmnopqrstuvwxyz".
> 01 y pic x(26).
> 01 i pic 99.
> 01 j pic 99.
> procedure division.
> main.
> compute j = function length(x).
> perform next-i varying i from 0 by 1
> until i is greater than j.
> stop run.
> next-i.
> move x to y.
> if i is > 0 and i < j perform
> move function reverse(y(1:i)) to y(1:i)
> move function reverse(y(i + 1:j - i)) to y(i + 1:j - i)
> move function reverse(y) to y
> end-perform.
> display i space y.
>
> -- Elliot
>