?
Solved

Not returning from a function

Posted on 1998-12-29
6
Medium Priority
?
169 Views
Last Modified: 2010-05-03
This may be a silly question. I want to call a function and, depending on the result, NOT return to the originating sub routine (if an error occurs for example). Can this be done? Have I missed something really obvious?

Thank you for any help you can give.

Peter
0
Comment
Question by:eccles
[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
  • 2
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
mukvij earned 600 total points
ID: 1452923
Yes This can be done but this is not a good programming practice. Depending on the condition you can branch to some other subroutine from the function . From there to another one and so on. You may choose to end your application from one of these subroutines. But the origional procedure is still in calling chain. Control returns to that procedure unless you choose to end the application from other brach in calling chain.
0
 

Author Comment

by:eccles
ID: 1452924
I understand. So control will ultimately return to the originating function/sub unless I terminate the application. Is this final? Is there no way around this? I really don’t want to have branch off indefinitely in the application.

Pete


0
 
LVL 12

Expert Comment

by:mark2150
ID: 1452925
Don't do this. You're going to wind up with an app that generates GPF's. You have to return from a function in order to clean up the internal stack. If you don't, your app will corrupt memory and eventually choke. Are you trying to write *buggy code*?

Allow the function to return and return a flag value so you know if you should trigger your error exit. If your code is not structured to handle this, then REWRITE it. It may be a PITA for *YOU* to rewrite, but it will be an even *BIGGER* PITA for the users when your app goes belly up and dumps their data.

If you don't *care* about the users then turn in your "I'm a programmer" card and go into a different trade. :-(

M

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:mukvij
ID: 1452926
I totally agree with mark. As I said earlier branching off indefinitely is not a good programming practise as it does not confirm to standards of structured programming. I also agree with the idea given by Mark to have function return some flag based on which you can decide what to de next.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1452927
Yeah, it's code like that which has given BASIC it's bad rep among programming languages.

If you were to write something like that in *MY* shop you'ld be looking for a new job.

M

0
 

Author Comment

by:eccles
ID: 1452928
Thank you mukvij for your comments and help. Mark, please get off your high horse! It was a QUESTION for gods sake!!! For your information I have already written the code with each function returning a status code. I asked the question to see if there was a better way of doing it. I do not pretend to know everything about programming (unlike your self).

Once again mukvij thank you for your help.

Pete

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

719 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