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

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

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

Post 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.
Tranquil
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Put the End statement inside the DeInit procedure.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Why not call your procedure Cleanup() and put this end in it ?
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Hm okay. Whats going on my mind asking so stupid feature requests!? :oops:

I think I'm getting old... :P
Tranquil
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Tranquil wrote:I think I'm getting old... :P
Bollocks, you're just spending too much time hacking localhost... ;)
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post 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
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Fred wrote:Why not call your procedure Cleanup() and put this end in it ?
Exactly what I just posted.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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:.
Post Reply