Page 1 of 1
Exit if
Posted: Mon Aug 28, 2006 11:26 am
by Michael Vogel
I'd like to have a "Exit if" line instead of the "If Then Break" thing...
Code: Select all
Repeat
;
If GetAsyncKeyState_(#VK_ESCAPE)
Break
EndIf
;
ForEver
...it's just a little bit more compact, that's all...
Code: Select all
Repeat
;
Exit If GetAsyncKeyState_(#VK_ESCAPE)
;
ForEver
[/code]
Re: Exit if
Posted: Mon Aug 28, 2006 12:47 pm
by PB
In the meantime you can do this:
Code: Select all
Macro ExitIf (code)
If code : Break : EndIf
EndMacro
Repeat
ExitIf (GetAsyncKeyState_(#VK_ESCAPE))
ForEver
Posted: Fri Sep 01, 2006 4:43 pm
by fsw
Actually because of PureBasic's naming convention it should be:
Break
BreakIf

Posted: Fri Sep 01, 2006 7:39 pm
by Flype
good tip.
so, just to finish the story :
Code: Select all
Macro BreakIf(code, depth)
If (code) : Break depth : EndIf
EndMacro
For i = 0 To 10
For j = 0 To 10
BreakIf((i=2) And (j=3), 2)
Next
Next
Debug i
Debug j
Posted: Fri Sep 01, 2006 8:01 pm
by Dr. Dri
yo can also add "= 1" after depth to make it optional
Dri

Posted: Fri Sep 01, 2006 8:46 pm
by Trond
I suggest allowing a dynamic expression for BreakLevel. If the BreakLevel is 0 then it won't break.