Re: How can I STOP a cursed recursion?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Dan Moyer wrote:
> 
> Igor Kachan wrote:
> > 
> > Dan Moyer wrote:
> > > 
> > > 
> > > With some difficulty, I built a recursive procedure, which seems to work
> > > fine, except that I can't get it to STOP.
> > > 
> > > It knows when it gets to where it should stop, & I put return in at that
> > > point, & when that didn't work, I set an external variable to 1
> > > (=finished)
> > > when it got to that point, and added a test at the beginning of the
> > > procedure
> > > to "return" if it saw that var "finished", but that didn't work either.
> > > 
> > > The procedure was to take a sequence of sequences like what "folder" would
> > > have when adding items to a TreeView, and go thru them to compute the
> > > correct
> > > positions to put those items into in a "horizontal" treeView. The
> > > procedure
> > > worked thru the items in a correct fashion, got to the last item just
> > > below
> > > the root item, knew it was where it should stop, but continues to maybe 
> > > "unravel" previous left-over recursions, or something????? 
> > > 
> > > Is there some way to just STOP a procedure, even if it has been working
> > > recursivly??  Or maybe recursion is supposed to be limited to FUNCTIONS?
> > > 
> > > 
> > > procedure Help!()
> > >   print(1,"help!")
> > >   Help{}
> > >   -- How can I stop!?
> > > end procedure
> > > 
> > > Help!
> > > 
> > > Dan
> > 
> > 
> > Hi Dan,
> > 
> > Try please:
> > }}}
<eucode> 
> > procedure Help()
> >  if get_key()!=-1 then return end if
> >   print(1,"help!")
> >   Help()
> >   -- How can I stop!?
> > end procedure
> > Help()
> > </eucode>
{{{

> > 
> > Regards,
> > Igor Kachan
> > kinz at peterlink.ru
> 
> Thanks Igor, but I want the *procedure* to stop itself when it sees by test
> that it should be finished, not a user action stop it.
> 
> eg:
>  }}}
<eucode> 
>  procedure Help()
>      print(1,"help!")
>    Help()
>    if getTime() = 6am then
>       STOP! -- How can I let the procedure *stop itself*!?
>    end if
>    
>  end procedure
>  Help()
>  </eucode>
{{{

> 
> Dan

Ok, no problem, try please:
integer n n=0
procedure Help()
 if n=5 then return end if
  puts(1,"help!")
    n+=1
    Help()
end procedure
Help()

atom T T=time()
procedure Help_()
 if time()-T > 20 then return end if
  puts(1,"help!")
    Help_()
end procedure
Help_()


Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu