Restored from previous forum. Originally posted by Franco.
I also made some workaround with procedures like that:
Code: Select all
Procedure InitGadgets(GadgetMax)
If InitGadget(GadgetMax) : Else : End : EndIf
EndProcedure
Code: Select all
Procedure NewWindow(WinID,X,Y,sX,sY,Flag,Title$)
If OpenWindow (WinID,X,Y,sX,sY,Flag,Title$) : Else : End : EndIf
EndProcedure
Code: Select all
Procedure NewGadgetList(WinID)
If CreateGadgetList(WinID) : Else : End : EndIf
EndProcedure
because sometimes it is annoying to do:
Code: Select all
If InitGadget(GadgetMax)
If OpenWindow (WinID,X,Y,sX,sY,Flag,Title$)
If CreateGadgetList(WinID)
; lets go with the code...
; bla,bla
; how long is the following code?
EndIf
EndIf
EndIf
End
instead of:
Code: Select all
InitGadgets(#NbGadgetMax)
NewWindow(0, 200, 200, 320,240, #PB_Window_SystemMenu ,Name$)
NewGadgetList(WindowID())
; lets go with the code...
; bla,bla
; how long is the following code?
End
If something failes with InitGadget/OpenWindow/CreateGadgetList (and so on...) you can close your application anyway.
And if you wish an error message you can change your procedure to:
Code: Select all
Procedure InitGadgets(GadgetMax,ErrorMsg$)
If InitGadget(GadgetMax) : Else : MessageRequester("ERROR",ErrorMsg$,0) : End : EndIf
EndProcedure
or something like that.
IMHO it would make the code clearer, nicer and more up to date...
BTW: Why is there no 'IfNot' or a 'If Not' command?
For now it has to be:
Code: Select all
If CreateGadgetList(WinID) : Else : End : EndIf
Instead of:
Code: Select all
If Not CreateGadgetList(WinID) : End : EndIf
Have a nice day...
Franco
Edited by - franco on 13 December 2001 16:47:10