?
Solved

"jumping" within a TRY...EXCEPT

Posted on 2003-03-06
7
Medium Priority
?
192 Views
Last Modified: 2010-04-04
Hi ...
  I've got a situation in my app where I need to go *back* to a point in my main code (within the TRY) after the EXCEPT code has executed. To illustrate:

TRY
  ...
  ...
  ...

gohere:

  ...
  ...
EXCEPT
  ...
  ...
END;


...I've tried using a goto statement ('goto gohere') within the scope of the EXCEPT, and also after the END; but both result in a "[Error] 'GOTO  leads into or out of TRY statement".

Is there any way to do this?

Thanks
   Shawn


0
Comment
Question by:aztec
[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
7 Comments
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 200 total points
ID: 8086081
GOTOs are BAD.

var
  bFaild: Boolean;

begin
  repeat
    try
      {do your stuff}
      bFailed := false;
    except
      bFailed := true;
    end;
  until not bFailed;
end;
0
 
LVL 1

Expert Comment

by:jturpin
ID: 8088308

I agree gotos are a curse.

Or if you do not want to do the whole try block again then simply turn the code segment into a procedure you can call from inside the try block, and then again from inside the exept block.


procedure ProcX;
begin
  .
  .
  .
end;

try
  ProcX;
except
  .. code to fix the error condition.
  ProcX;
end;

0
 

Expert Comment

by:SanDao
ID: 8100335
Try  
  TRY
   ...
   ...
   ...

  gohere:

   ...
   ...
  EXCEPT
   ...
   ...
  END;
Finally
   ...//You must to do after except!
end;

Is that all right?
0
Technology Partners: 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!

 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 8100342
How about a bit of feedback, aztec??

SanDao, I think you missed the point, aztec is trying to call the failed code repeatedly (obviously until the code passes because of changed values).

Stu
0
 

Author Comment

by:aztec
ID: 8100736
This does the trick - thank you Stuart

Cheers
   Shawn
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 8100756
No problems, Shawn!

Thanks for the grading.

Stu.
0
 

Expert Comment

by:SanDao
ID: 8124042
Oh,Yeah, I see!
Thank you for your help,Stuart!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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