Page 2 of 2

Posted: Fri Mar 19, 2004 1:39 pm
by GedB
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.

Posted: Fri Mar 19, 2004 2:38 pm
by Kale
The advantage of Do or Die is that the exception handling can easily be ignored.
Thats exactly why i like your method :)
Kale's HandleError is almost there...
Not mine, i think i 'borrowed' the idea from the IDE source! Beriko? :)

Posted: Wed Apr 26, 2006 12:48 pm
by Psychophanta
This great feature still works fine in 4.0 :!: :D :idea: :wink: 8) :) :o

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)
Please Fred keep it working :wink:

Posted: Wed Apr 26, 2006 1:18 pm
by Joakim Christiansen
I like the idea, do this or do that, never seen it before that simple! :D

Posted: Mon May 01, 2006 12:08 pm
by SFSxOI
I'm still learning this stuff and I don't understand why its not safe.

Why is it not safe?

I kinda like it, even tho I don't understand why its not safe.

Fred wrote:This is not safe, I suggest to always put an 'IF' before, as an expression requiers a keyword.

Posted: Mon May 01, 2006 12:20 pm
by Psychophanta
SFSxOI wrote:I'm still learning this stuff and I don't understand why its not safe.
Same here.
Please Fred, could you explain a little.

Posted: Mon May 01, 2006 5:36 pm
by GedB
Officially all expressions in PB should be accompanied by a keyword.

That means that this is an illegal expression. The fact that it works could be viewed as a bug.

Posted: Thu May 04, 2006 2:42 pm
by josku_x
correction: as a GOOD bug. :wink:

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
The method that is COOL:

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")
:?:

Posted: Thu May 04, 2006 2:52 pm
by Joakim Christiansen
Indeed :D
Fred, pleas let us have this! :D And make it safe :D

Posted: Thu May 04, 2006 4:54 pm
by josku_x
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

Posted: Thu May 04, 2006 4:58 pm
by Psychophanta
Joakim Christiansen wrote:Indeed :D
Fred, pleas let us have this! :D And make it safe :D
Besides, the legibility is great! Nothig to envy to If...EndIf :)