> But I really do like your COMPUTE and using LENGTH OF to plug in the
correct
> table limit without requiring that the number of occurrences having to be
> updated in two places, and I will be adding that code if I get involved in
our
> conversion from DOS/VS COBOL (FCOBOL) to COBOL/VSE (IGYCRCTL).
>
> Do you have a feel for LENGTH OF name vs. FUNCTION LENGTH(name)? I'm more
> inclined towards FUNCTION LENGTH(name) because that is standard COBOL
(optional
> intrinsic functions), whereas LENGTH OF is an IBM extension, no?
>
> Mark A. Young
>
Mark,
In the COBOL/370 Book that I have, I've not seen any severe restrictions
using the LENGTH Intrinsic Function, including usage with a table element. I
would imagine then maybe one of our esteemed colleagues could test out this
theory in their own COBOL environment. Here's the example everyone:
03 WS-MAX-SUB PIC S9(09) BINARY.
03 WS-TABLE-REC.
05 WS-TABLE OCCURS 100 TIMES.
07 WS-TABLE-ELEMENT-01 PIC X(10).
07 WS-TABLE-ELEMENT-02 PIC X(20).
07 WS-TABLE-ELEMENT-03 PIC X(30).
COMPUTE WS-MAX-SUB = (FUNCTION LENGTH (WS-TABLE-REC) /
FUNCTION LENGTH (WS-TABLE (1))).
Under the IBM umbrella, intrinsic functions are supported in COBOL/370,
COBOL/MVS, COBOL/VSE and COBOL/390 but not COBOL2.
Some other usage's are with Reference Modification and INSPECT.
HTH....
Cheers,
WOB,
Atlanta
This will only work if there are no COMP or BINARY items on machines
where such items must be on specific boundaries.
Try to change ELEMENT-01's picture to PIC X(11) and -02's to PIC S9(4) COMP.
The compilers insert slack bytes to align binary stuff on (say) word
boundaries.
This makes the size of WS-TABLE-REC too large,
A pity though, because it was really neat.
(Donald, sorry about the poor SAPM ratio here)
Leif Svalgaard wrote in message <35c7c...@news1.ibm.net>...
Now I remember: the FUNCTION can only be used in COMPUTE the other one
can be used anwhere. This is an MVS 'extension' and they will be
correcting the 'documentation' shortly.
If only I could fix my bugs so easily :-)
Ken
<much snippage>
>
> In the COBOL/370 Book that I have, I've not seen any severe
restrictions
>using the LENGTH Intrinsic Function, including usage with a table element.
<more snippage>
Just as a side comment - that not MANY of you may need to worry about yet.
There are some well-defined rules for both the LENGTH OF special register
and the LENGTH intrinsic function about how to handle items/groups with DBCS
items included. I don't have my manuals handy - but I do know that J4 and
WG4 worked quite a bit on this issue for the next Standard. The problem
being (obviously?) do you want the number of character positions or do you
want the number of bytes? J4 was able to come with some examples of each.
FYI - in the next Standard (and in some compilers - for example Micro Focus)
this rule is changed so that a numeric (or integer) function CAN be used
anywhere that a numeric item can be used as a sending item.
> WOB wrote:
> >
> >
> > COMPUTE WS-MAX-SUB = (FUNCTION LENGTH (WS-TABLE-REC) /
> > FUNCTION LENGTH (WS-TABLE (1))).
> >
>
> Now I remember: the FUNCTION can only be used in COMPUTE the other one
> can be used anwhere.
No, for exampleDIVIDE FUNCTION LENGTH (WS-TABLE-REC)
BY FUNCTION LENGTH (WS-TABLE (1))
GIVING WS-MAX-SUB
will work too.
> This is an MVS 'extension' and they will be
> correcting the 'documentation' shortly.
FUNCTION is not an MVS extension. It is a regular part of the COBOL standard now,
added in1989 to the 1985 standard.
The COBOL Frog
--
Dut: Vandaag is de eerste dag van de rest van je leven! Maak er wat van!
Eng: Today is de first day of the rest of your life! Use it!