Re: return command



"marc hoffman" <mh@xxxxxxxxxxxxxxx> wrote in message
news:43a878c0$1@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> right. but if you "exit" es executing, by definition there wasn't an
> exception (or it wouldn't have gotten to tour "exit"). so the behavior of
> finally in case you "exit" cannot depend on whether there's an exception,
> because when you're exciting, there never is an exception ;)

Marc,
This is a good learning experience for me! I've done some experiementing,
like so:

try
// anything here
exit;
finally
MessageDlg ('finally block executed', mtInformation, [mbOK], 0);
end;

Obviously, you're absolutely right, and the message dialog does appear.
This is great! I have some old code to revisit, where if a test condition
was met, I manually freed something that was also freed in the finally block
and then exited. I guess this is a good reason to limit the use of exit,
huh?

I tried substituting halt for exit, and it halts without executing the
finally block, which is what I expected.

Also substituted a goto that landed me just after the last end, and that
wouldn't compile. I find it interesting that I can redirect the flow out of
the try..finally block and the function and it allows that and automatically
executes the code in the finally block, but it won't let me redirect flow
out of the try..finally block but stay within the function. Wonder why it
allows one but not the other? At first glance it would seem that the
consistent thing to do would be to allow the goto, but automatically execute
the code in the finally block. Not that I wanna use a goto in that way (or
any way), but it just didn't seem consistent to me.

Thanks,
Van


.



Relevant Pages

  • Re: Terminating Access Applications
    ... frmTest is OPEN and you exit the application by calling any of these three exit ... Executing a routine that closes all open forms prior to calling any of the ... all Form member variables are still available in both Form_Unload ... I also added error handling to catch an issue ...
    (microsoft.public.access.formscoding)
  • Re: Alternative to the STOP statement?
    ... regardless of whether an exception is thrown, why is a named construct ... getting out of the block (such as a GOTO, or for that matter, an exit). ...
    (comp.lang.fortran)
  • Re: Exit Value = 35584 from Java.lang.Process
    ... Runtime.exec *does not* invoke a command processor. ... zero-means-success is a common convention but is by no means required. ... the batch file was executing. ... TheNoClassDefError is unrelated to the exit value and just happened to ...
    (comp.lang.java.programmer)
  • Creating MSHTML::TxtRange Object Causes Function to Exit w/o Excep
    ... will cause your C# function to simply exit without throwing any exception, ... and without executing any code beyond where you called the COM function? ... I am trying to create a TxtRange object on a Selection Object like thus: ...
    (microsoft.public.dotnet.framework.interop)
  • Re: cobol array editing output
    ... if the user enters 0 then the program should exit that perform. ... > not continue executing the rest of para1? ... condition on the Perform is not tested until para1 has executed ... If you've got optional code in para1, ...
    (comp.lang.cobol)