Functions like DrawingMode,DrawingFont,CustomFilterCallback,FrontColor and BackColor should return the previously used value.
This could help to create more generic custom drawing commands, because we could set them back to the original value.
This would be also very handy for OnErrorCall. However there it is not that easy, because there are different possiblilites (OnErrorCall, OnErrorDefault,OnErrorExit or OnErrorGoto).
Therefore we would need an additional command like e.g. GetOnErrorType()...
Some functions should return the previously used value
-
- Addict
- Posts: 4779
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Some functions should return the previously used value
Agreed.
I've written my own wrapper OnErrorCallEx():
Similar wrappers can be written for the other functions under consideration. However, it would be much more elegant if this functionality would be built into PB.
So +1 from me.
I've written my own wrapper OnErrorCallEx():
Code: Select all
Procedure.i OnErrorCallEx (*proc)
; in : address of the new error handling procedure
; out: address of the previous error handling procedure
Static *prev
OnErrorCall(*proc)
Swap *prev, *proc
ProcedureReturn *proc
EndProcedure
;=========== How to use OnErrorCallEx() ===========
Procedure GeneralErrorHandler()
; [...]
EndProcedure
OnErrorCallEx(@GeneralErrorHandler())
;--------------------------------------------------
Procedure SpecialErrorHandler()
; [...]
EndProcedure
Procedure Demo()
Protected *prevErrHandler = OnErrorCallEx(@SpecialErrorHandler())
; [...]
If *prevErrHandler <> #Null
OnErrorCallEx(*prevErrHandler)
EndIf
EndProcedure
So +1 from me.