Procedure error

The basics of how to develop, test, and use models.
Post Reply
MishaZ

Procedure error

Post by MishaZ »

When I try to compile my new code (big part is cell template), I get an error stating "procedure too big". It points to a loop that is repeated for every section exactly the same way -- the curious thing is that the loop in question is not the first one in code. Removing the "wrong" line out of the loop just makes the compiler point to the next line. If I comment out the whole loop, the error points to the next loop. All this makes me think that something other than syntax is wrong.

Any ideas?
ted
Site Admin
Posts: 6300
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Procedure error

Post by ted »

hoc's parser complains if a procedure contains too many lines of code. This is one
aspect of hoc that could reasonably be called "a feature, not a bug" because it
discourages the use of giant procedures, which are hard to develop and maintain.
However, for this minor limitation of hoc to be a truly effective "feature," the parser
should really issue its complaint much sooner than it does.

The generic workaround is to split the offending proc into a bunch of smaller procs,
and call them individually. In your particular case, I suspect there is an even better
approach: if in fact your giant proc consists of a sequence of loops that are "repeated
for every section exactly the same way," why not use a forall statement? Or if you
only want to deal with a select group of sections, put them in a SectionList, then
use a forsec statement?
MishaZ

Post by MishaZ »

Thank you! this is what I suspected...just never saw such an error before.
I will try to "generalize" the loops, but it will be tricky since I use array variables - will need to keep track of them.
Post Reply