HP3000-L Archives

March 1998, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Mel Bartels <[log in to unmask]>
Reply To:
Mel Bartels <[log in to unmask]>
Date:
Thu, 5 Mar 1998 09:35:50 -0800
Content-Type:
multipart/mixed
Parts/Attachments:
text/plain (2056 bytes) , application/ms-tnef (3666 bytes)
As an earlier respondent noted, you can use COBOL tables to build a
stack area, where the function or paragraph state and variables are
preserved by pushing them onto the stack, then popping them from the
stack when that particular instance of the function is returned to.
 The code will look strange to someone not used to seeing stacks
implemented in COBOL, but if you must preserve variables and pass
variables while recusively calling functions/paragraphs, this is the
best way I know to handle it. (Either that or write a small C coded
stub that's called...)


Mel Bartels
Programmer/Analyst
Goshen Admin
Willamette Industries, Inc.
85647 Hwy 99 South
Eugene, OR 97405
Phone 541-744-4600
Fax 541-988-5570
mailto: [log in to unmask]


----------
From:  Therm-O-Link [SMTP:[log in to unmask]]
Sent:  Thursday, March 05, 1998 8:45 AM
To:  HP3000-L
Cc:  SIGCOBOL-L
Subject:  [COBOL] Recursion Supported?

Glenn Cole wrote:

>(I tend to think of this as "circular calls" rather than recursion,
>but that may be just me.)

>I verified that this calling sequence (A->B->A) is supported
>without warning of any kind, and it works just fine.

I rewrote the program to recursively perform a paragraph, and it
worked just fine.  Now, paragraph A performs paragraph B, which
may perform paragraph A again.  I haven't tried a case where
A would perform B during the second perform, leading to a third
perform of A.  The really hard part is keeping track of what
chain you're traversing in the data set, and resetting the
chain back to the original when you've finished the second
chain.  I suppose you could table-ize the chain pointers so
that a number of different levels of B-O-M could be traversed
without difficulty (from the program's perspective, not the
programmer's!).  Luckily we only have a three-tier (at most)
B-O-M.

Thanks to all who responded.

Jim Phillips                            Manager of Information
Systems
E-Mail: [log in to unmask]      Therm-O-Link, Inc.
Phone: (330) 527-2124                   P. O. Box 285
  Fax: (330) 527-2123                   Garrettsville, Ohio  44231



ATOM RSS1 RSS2