For Programmers: Free Programming Magazines  


Home > Archive > Cobol > October 2004 > X Occurs 1 To 10 Times Depending On Y ??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author X Occurs 1 To 10 Times Depending On Y ??
cctj_82

2004-09-29, 8:13 pm

how can we explain the statement ?
X OCCURS 1 TO 10 TIMES DEPENDING ON Y

what's the meaning of 'DEPENDING ON'

thanks, it's better to give a example.
Michael Mattias

2004-10-02, 3:55 pm

"cctj_82" <cctj_82.1di51n@mail.codecomments.com> wrote in message
news:1096720874.cmFn0kIDyuQlA81/lsePVw@tng...
> how can we explain the statement ?
> X OCCURS 1 TO 10 TIMES DEPENDING ON Y
>
> what's the meaning of 'DEPENDING ON'


Which part of the explanation in your manual is insufficient?




JerryMouse

2004-10-02, 3:55 pm

cctj_82 wrote:
> how can we explain the statement ?
> X OCCURS 1 TO 10 TIMES DEPENDING ON Y
>
> what's the meaning of 'DEPENDING ON'
>
> thanks, it's better to give a example.


If "Y" is 5, there are 5 "Xs"

Or,

"You can reserve up to ten hotel rooms depending on how many people in your
party."


docdwarf@panix.com

2004-10-02, 3:55 pm

In article <Cux7d.13326$Qv5.902@newssvr33.news.prodigy.com>,
Michael Mattias <michael.mattias@gte.net> wrote:
>"cctj_82" <cctj_82.1di51n@mail.codecomments.com> wrote in message
>news:1096720874.cmFn0kIDyuQlA81/lsePVw@tng...
>
>Which part of the explanation in your manual is insufficient?


Curious how the original didn't show up on my news-server... but, Mr
Mattias, answering a question with a question is no answer at all. A
different response might be:

'The meaning is the result of the audience's interpretation so 'the
meaning of 'DEPENDING ON'' is depending on something else.'

DD

Lueko Willms

2004-10-02, 3:55 pm

.. Am 29.09.04
schrieb cctj_82.1ddidn@mail.codecomments.com (cctj_82)
auf /COMP/LANG/COBOL
in 1096713992.zXGPew9W5jNUhJqxzLYpNw@tng
ueber X Occurs 1 To 10 Times Depending On Y ??

c81> X OCCURS 1 TO 10 TIMES DEPENDING ON Y
c81>
c81> what's the meaning of 'DEPENDING ON'

an example would be like this:

--------- schnipp -----------------------------------------

identification division.
program-id.
occurs-example.

data division.
working-storage section.

01 a-string-record.
02 its-length PIC 9(4) comp.
02 the-string.
03 filler pix x occurs 1 to 80 times
depending on its-length.


procedure division.
the-only section.
its-beginning.
move 80 to its-length
move all '8' to the-string
move 20 to its-length
move all 'twenty' to the-string
display the-string
move 80 to its-length
display the-string
perform with test after
varying its-length from 5 by 5
until its-length >= 80
display the-string
end-perform
Robert Jones

2004-10-02, 8:55 pm

cctj_82 <cctj_82.1ddidn@mail.codecomments.com> wrote in message news:<1096713992.zXGPew9W5jNUhJqxzLYpNw@tng>...
> how can we explain the statement ?
> X OCCURS 1 TO 10 TIMES DEPENDING ON Y
>
> what's the meaning of 'DEPENDING ON'
>
> thanks, it's better to give a example.


Hello,

The "DEPENDING ON" phrase of the OCCURS clause of a data description
specifies the current logical number of occurrences that the table
contains. It is a standard construct of COBOL and is explained in the
language reference manuals and application programmer guides of all
the main compilers. The value of "Y" is a numeric value specifying
the current number of occurrences of the the table elements. However,
despite it implying that the table takes less space when the value of
"Y" is less than "10", this is not true, the table always uses
physical space for ten occurrences. The difference from an OCCURS
clause without the DEPENDING ON phrase is applicable when
moving/comparing the table to other data items or reading and writing
to a file, when only the logical number of occurrences are moved,
compared, read or written.

Robert
Russell Styles

2004-10-03, 3:55 am


"Robert Jones" <rjones0@hotmail.com> wrote in message
news:6dd8322.0410021150.b7fce2f@posting.google.com...
> cctj_82 <cctj_82.1ddidn@mail.codecomments.com> wrote in message

news:<1096713992.zXGPew9W5jNUhJqxzLYpNw@tng>...
>
> Hello,
>
> The "DEPENDING ON" phrase of the OCCURS clause of a data description
> specifies the current logical number of occurrences that the table
> contains. It is a standard construct of COBOL and is explained in the
> language reference manuals and application programmer guides of all
> the main compilers. The value of "Y" is a numeric value specifying
> the current number of occurrences of the the table elements. However,
> despite it implying that the table takes less space when the value of
> "Y" is less than "10", this is not true, the table always uses
> physical space for ten occurrences. The difference from an OCCURS
> clause without the DEPENDING ON phrase is applicable when
> moving/comparing the table to other data items or reading and writing
> to a file, when only the logical number of occurrences are moved,
> compared, read or written.
>
> Robert


The bit about how much space the array takes up can differ
depending on implementation and compiler options.

If your compiler does allow variable length arrays (eg Microfocus and
ODOSLIDE), be careful. Some verbs might not work as you expect. I
think that I remember that the initialize verb was not useable, at least
with
the old 16 bit compiler. I have not tried it with NetExpress.

To make an array truly variable length, you had to use memory
allocation,
not working storage.

But it could be made to work.


William M. Klein

2004-10-03, 3:55 pm

As far as I know, an ODO *never* (at least in any standard conforming) compiler
impacts the amount of storage allocated - only the amount "currently
accessible".

The Micro Focus ODOSLIDE directive attempts to emulate an IBM mainframe
*extension* to the Standard that allows an ODO to be nested within another ODO
and/or to have "fixed" data following an ODO item, e.g

01 Full-Item-type1.
05 ODO1.
10 Elem1 occurs 1 to 10 times depending on Some-Counter
15 Elem2 occurs 1 to 100 times depending on Other-Counter
Pic X.

01 Full-Item-type2.
05 ODO2.
10 Elem3 Occurs 1 to 10 times depending on Counter3
Pic X.
05 Post-ODO-Fixed Pic X(10).

***

From reading the "Substantive Change Potentially effecting" section of the '85
Standard, one or both of these were "allowed" in the '74 Standard, but not well
defined there (or at least the rules prohibiting them wasn't clear).

In both cases, the amount of storage "required" for Full-item-type1 and
Full-item-type2 is (still - just like standard conforming ODO's) "fixed" - but
the amount of storage accessible is dependent upon the current values of the
various counters. Also, whether the item is used as a "sending" or "receiving"
item can impact what is accessible - but not the amount of storage allocated.

--
Bill Klein
wmklein <at> ix.netcom.com
"Russell Styles" <rws0203@comcast.net> wrote in message
news:9I6dna75c-HtB8LcRVn-tg@giganews.com...
>
> "Robert Jones" <rjones0@hotmail.com> wrote in message
> news:6dd8322.0410021150.b7fce2f@posting.google.com...
> news:<1096713992.zXGPew9W5jNUhJqxzLYpNw@tng>...
>
> The bit about how much space the array takes up can differ
> depending on implementation and compiler options.
>
> If your compiler does allow variable length arrays (eg Microfocus and
> ODOSLIDE), be careful. Some verbs might not work as you expect. I
> think that I remember that the initialize verb was not useable, at least
> with
> the old 16 bit compiler. I have not tried it with NetExpress.
>
> To make an array truly variable length, you had to use memory
> allocation,
> not working storage.
>
> But it could be made to work.
>
>



Michael Mattias

2004-10-04, 8:55 pm

"cctj_82" <cctj_82.1di51n@mail.codecomments.com> wrote in message
news:1096720874.cmFn0kIDyuQlA81/lsePVw@tng...
> how can we explain the statement ?
> X OCCURS 1 TO 10 TIMES DEPENDING ON Y
>
> what's the meaning of 'DEPENDING ON'


Which part of the explanation in your manual is insufficient?




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com