Page 1 of 1

End [@Procedure(),Value.l,Timeout.l)

Posted: Fri Mar 24, 2006 1:47 pm
by Tranquil
Just a thought.

Sometimes it could be usefull to De-Init some stuff if quitting an application due to fatal errors in procedures. Then often I use the END command inside procedures to quit the app. But before I need to release and free some API Stuff using an own Procedure DeInitEND() and sometimes I forget this before the END command.

So, it would be nice to specifiy optionaly an Procedure to the END command which will be executed before the real END command is executed.

Not a big deal, maybe makes thinks a little big more easy.

Thanks for reading.

Posted: Fri Mar 24, 2006 2:05 pm
by Trond
Put the End statement inside the DeInit procedure.

Posted: Fri Mar 24, 2006 2:46 pm
by Tranquil
Sorry, my mistake.

I explained a bit wrong. What I'm searching for is something like:

SetEndProc(@Procedure())


So, that when I call End after this command anywhere at the code, the procedure "Procedure()" is called before real ending.

Posted: Fri Mar 24, 2006 2:51 pm
by Fred
Why not call your procedure Cleanup() and put this end in it ?

Posted: Fri Mar 24, 2006 3:03 pm
by Tranquil
Hm okay. Whats going on my mind asking so stupid feature requests!? :oops:

I think I'm getting old... :P

Posted: Fri Mar 24, 2006 3:04 pm
by traumatic
Tranquil wrote:I think I'm getting old... :P
Bollocks, you're just spending too much time hacking localhost... ;)

Posted: Fri Mar 24, 2006 3:40 pm
by helpy
PB 4.0:

Code: Select all

Macro End(ExitCode=0)
  CleanUpAndEnd(ExitCode)
EndMacro

Procedure CleanUpAndEnd(ExitCode)
  If ExitCode <> 0
    MessageRequester("CleanUP","Programm will be terminated!" + #CRLF$ + #CRLF$ + "ExitCode: " + Str(ExitCode))
  EndIf
  End ExitCode
EndProcedure

Procedure test1(c)
  If c=5
    End(1)
  EndIf
EndProcedure

;test1(1)
test1(5)
End()
If you use End() or End(ExitCode) then the procedure CleanUpAndEnd() is called. If you only use End (without brackets) the program terminates immediately.

cu, helpy

Posted: Fri Mar 24, 2006 4:02 pm
by Trond
Fred wrote:Why not call your procedure Cleanup() and put this end in it ?
Exactly what I just posted.

Posted: Fri Mar 24, 2006 4:11 pm
by Fred
Trond wrote:
Fred wrote:Why not call your procedure Cleanup() and put this end in it ?
Exactly what I just posted.
Seems like he didn't understood your post :wink:.