Link to home
Start Free TrialLog in
Avatar of aztec
aztec

asked on

"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


ASKER CERTIFIED SOLUTION
Avatar of Stuart_Johnson
Stuart_Johnson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

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;

Avatar of SanDao
SanDao

Try  
  TRY
   ...
   ...
   ...

  gohere:

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

Is that all right?
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
Avatar of aztec

ASKER

This does the trick - thank you Stuart

Cheers
   Shawn
No problems, Shawn!

Thanks for the grading.

Stu.
Oh,Yeah, I see!
Thank you for your help,Stuart!