Recent

Author Topic: Leave the procedure  (Read 19407 times)

asdf

  • Sr. Member
  • ****
  • Posts: 310
Leave the procedure
« on: November 13, 2010, 01:21:26 am »
procedure
var
begin //procedure
if A then
if B then
begin
.
.
if not C then // How can I leave the procedure immediately?



end;
end; // procedure, begin
Lazarus 1.2.4 / Win 32 / THAILAND

mas steindorff

  • Hero Member
  • *****
  • Posts: 560
Re: Leave the procedure
« Reply #1 on: November 13, 2010, 02:01:03 am »
exit to leave
break to kill out of a for loop
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12593
  • FPC developer.
Re: Leave the procedure
« Reply #2 on: November 13, 2010, 08:38:17 am »
And "continue" for the next iteration of a for loop.

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 268
Re: Leave the procedure
« Reply #3 on: November 13, 2010, 11:53:47 am »
There is also a "abort" :

begin

if not C then begin
abort;
end;

end;

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Leave the procedure
« Reply #4 on: November 13, 2010, 02:32:57 pm »
There is also a "abort" :
don't do that. ever. use exit.

mirce.vladimirov

  • Sr. Member
  • ****
  • Posts: 268
Re: Leave the procedure
« Reply #5 on: November 13, 2010, 03:40:00 pm »
Quote
don't do that. ever. use exit.

Why ?


captian jaster

  • Guest
Re: Leave the procedure
« Reply #6 on: November 13, 2010, 05:09:59 pm »
Quote
don't do that. ever. use exit.

Why ?


Because ivan17 told you not to do it  >:(
Nah.. Abort exits the whole program...
Exit is just the Procedure :p

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Leave the procedure
« Reply #7 on: November 15, 2010, 12:27:39 pm »
Because ivan17 told you not to do it  >:(

that should be a sufficient reason, but being in a good mood i'll tell you that abort will move the execution to the first (innermost) exception handling block it finds... or second if the first chooses not to handle that exception... or it may just shut the whole thing down if you have no except blocks around.

captian jaster

  • Guest
Re: Leave the procedure
« Reply #8 on: November 17, 2010, 12:49:34 am »
Because ivan17 told you not to do it  >:(

that should be a sufficient reason, but being in a good mood i'll tell you that abort will move the execution to the first (innermost) exception handling block it finds... or second if the first chooses not to handle that exception... or it may just shut the whole thing down if you have no except blocks around.
Oh okay..
When I did use "Abort" it was around when I first started

 

TinyPortal © 2005-2018