Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Michael Vogel
Addict
Posts: 2835 Joined: Thu Feb 09, 2006 11:27 pm
Contact:
Post
by Michael Vogel » Mon Aug 28, 2006 11:26 am
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]
PB
PureBasic Expert
Posts: 7581 Joined: Fri Apr 25, 2003 5:24 pm
Post
by PB » Mon Aug 28, 2006 12:47 pm
In the meantime you can do this:
Code: Select all
Macro ExitIf (code)
If code : Break : EndIf
EndMacro
Repeat
ExitIf (GetAsyncKeyState_(#VK_ESCAPE))
ForEver
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
fsw
Addict
Posts: 1603 Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest
Post
by fsw » Fri Sep 01, 2006 4:43 pm
Actually because of PureBasic's naming convention it should be:
Break
BreakIf
Flype
Addict
Posts: 1542 Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy
Post
by Flype » Fri Sep 01, 2006 7:39 pm
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
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Dr. Dri
Enthusiast
Posts: 243 Joined: Sat Aug 23, 2003 6:45 pm
Post
by Dr. Dri » Fri Sep 01, 2006 8:01 pm
yo can also add "= 1" after depth to make it optional
Dri
Trond
Always Here
Posts: 7446 Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway
Post
by Trond » Fri Sep 01, 2006 8:46 pm
I suggest allowing a dynamic expression for BreakLevel. If the BreakLevel is 0 then it won't break.