Do or Die
Rings,
That is pretty neat.
However, what I'm really after is a way of tucking away the testing code when creating windows and the like.
Kale's HandleError is almost there, but it is intrusive because HandleError becomes the first item on the line. You have to scan over for the OpenWindow.
The advantage of Do or Die is that the exception handling can easily be ignored.
That is pretty neat.
However, what I'm really after is a way of tucking away the testing code when creating windows and the like.
Kale's HandleError is almost there, but it is intrusive because HandleError becomes the first item on the line. You have to scan over for the OpenWindow.
The advantage of Do or Die is that the exception handling can easily be ignored.
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
This great feature still works fine in 4.0
Please Fred keep it working 







Code: Select all
Procedure error_end(message.s,message2.s)
MessageRequester(message.s,message2.s,#PB_MessageRequester_Ok):End
EndProcedure
hWnd.l=OpenWindow(0,0,0,80,40,"a window",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
hWnd.l Or error_end("Error","Something fails: i can't open window")
Delay(1000)

- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
correction: as a GOOD bug.
I think a command like this that would be 'safe' should be added to the next version of PB, because with this you can save time and source-size:
The SAFE method Fred recommended to use:
The method that is COOL:


I think a command like this that would be 'safe' should be added to the next version of PB, because with this you can save time and source-size:
The SAFE method Fred recommended to use:
Code: Select all
Procedure Die(Message$)
MessageRequester("Error", Message$, #MB_ICONERROR)
End
EndProcedure
Procedure ReturnValue(Value)
ProcedureReturn Value
EndProcedure
If ReturnValue(#False)
Else
Die("ReturnValue returned #false")
EndIf
Code: Select all
Procedure Die(Message$)
MessageRequester("Error", Message$, #MB_ICONERROR)
End
EndProcedure
Procedure ReturnValue(Value)
ProcedureReturn Value
EndProcedure
ReturnValue(#False) Or Die("ReturnValue returned #false")

- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
In PHP, you can use many keywords without having the IF or another keyword before it. For example, you can do this in PHP:
Code: Select all
$Value=$This AND $That
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact: