Solved

Return to start function?

Posted on 2001-06-21
4
176 Views
Last Modified: 2013-11-20
Hi experts,

I call function A(), A() calls B(),...., calls Z().
If something wrong in function Z(), program will be stoped by exit(0) in the function Z().
Now, I want it goes back to function A(), instead of stoped, if anything wrong in function Z().
I know we can do that by 'return' from z() to Y()....to A() but need hard work!

Any good suggestions?
0
Comment
Question by:learn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
migel earned 60 total points
ID: 6214017
Hi!
use exception mechanism
that is:
A()
{
try
{
B();
}
catch(int)
{
// something wrong in the call chain
}
}

B()
{
Z();
}

Z()
{
if (error condition)
 throw 5; // generate exception;
}
0
 
LVL 3

Expert Comment

by:cypherljk
ID: 6214019
learn,
  I don't know what you mean by 'something goes wrong' but take a look at using 'try' and 'catch' blocks.  If an error or exception is caught it will be passed back up the calling stack.  the calling stack is a list of the functions that are currently executing. For example if A(), A() calls B(),...., calls Z() and exception 1 happens in z() if your catch block in in z catchs errors/exceptions of type 1 you could call a() from there OR you could have the catch in a(). You'll need to look up exceptions handling as there are many ways you can handle and pass exceptions and errors.

My 2 cents...
0
 

Author Comment

by:learn
ID: 6214640
Thanks a lot, that works great.

Thanks to all experts as well.....
0
 
LVL 3

Expert Comment

by:cypherljk
ID: 6216884
close the reference to this ? in the c++ section

my 2 cents...
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 176
Creating Labels and Frequency list style reports in SAS code 9 114
post4 challenge 28 113
Line meaning 9 91
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question