Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

"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


0
aztec
Asked:
aztec
1 Solution
 
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
 
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
Independent Software Vendors: 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!

 
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

Featured Post

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now