"jumping" within a TRY...EXCEPT

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


aztecAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Stuart_JohnsonCommented:
GOTOs are BAD.

var
  bFaild: Boolean;

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jturpinCommented:

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
SanDaoCommented:
Try  
  TRY
   ...
   ...
   ...

  gohere:

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

Is that all right?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Stuart_JohnsonCommented:
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
aztecAuthor Commented:
This does the trick - thank you Stuart

Cheers
   Shawn
0
Stuart_JohnsonCommented:
No problems, Shawn!

Thanks for the grading.

Stu.
0
SanDaoCommented:
Oh,Yeah, I see!
Thank you for your help,Stuart!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.