Q:Breaking out of recursive procedures 
Author Message
 Q:Breaking out of recursive procedures

I've made a program with a lot of recursive procedures. I want to be able to
break out of these with Ctrl-Break or if a certain variable gets an
unexpected value. After this I want to return to my main procedure with the
stack down to where it was before I started running my recursive procedures.
I've tried saving the stack pointer and then just resetting it, but I still
get a stack overflow error after a while.
How do I solve this problem? Could anyone please help me?

Thanks in advance!



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Breaking out of recursive procedures


Quote:
>I've made a program with a lot of recursive procedures. I want to be able to
>break out of these with Ctrl-Break or if a certain variable gets an
>unexpected value. After this I want to return to my main procedure with the
>stack down to where it was before I started running my recursive procedures.
>I've tried saving the stack pointer and then just resetting it, but I still
>get a stack overflow error after a while.
>How do I solve this problem? Could anyone please help me?

>Thanks in advance!

I succeeded in getting out of a recursive procedure (in C++ not Pascal but the
same principle should apply to Pascal) by setting a variable (either global or
one you can pass as a parameter) to FALSE under certain conditions. The first
statement in the procedure is "if the variable is false, get out". This way, you
can walk the stack backwards until you are back at the main calling procedure.
Hope this helps.

--
Gabriel Beccar-Varela

----



Wed, 18 Jun 1902 08:00:00 GMT  
 Q:Breaking out of recursive procedures


Quote:
>I've made a program with a lot of recursive procedures. I want to be able to
>break out of these with Ctrl-Break or if a certain variable gets an
>unexpected value. After this I want to return to my main procedure with the
>stack down to where it was before I started running my recursive procedures.
>I've tried saving the stack pointer and then just resetting it, but I still
>get a stack overflow error after a while.
>How do I solve this problem? Could anyone please help me?

You need to save/restore BP as well.
--

http://www.armory.com/~jon                       Personal and Technical Pages
http://www.armory.com/~jon/hs/HomeSchool.html Home School Resource Pages



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help-recursive procedures

2. Recursive Procedure expert needed

3. InterBase Recursive Procedure

4. IB Recursive Stored Procedure

5. Help with Recursive Pascal Procedure

6. recursive procedure

7. Recursive Stored Procedure (?) Help

8. qs?.mb files and lost data

9. Database link'n'joining Qs

10. how to make multiple read outs - help

11. how do you make multiple read outs?

12. Table jumps outs edit mode newby

 

 
Powered by phpBB® Forum Software