When there's just one line of consequence, "If ... Then" looks cleaner, plus you'll get another tool to structure your code.
Code: Select all
If condition : doStuff : Endif
Code: Select all
If condition : doStuff : Endif
But you'd still need the Endif at the end. And that's what makes it clunky (imho).
Code: Select all
If/Then macro by PB. Usage: If <condition> Then (<code>)
Macro Then (code)
: code : EndIf
EndMacro
age=Val(InputRequester("If/Then example","How old are you?",""))
If age<21 Then (MessageRequester("Result","No beer drinking for you!"))
If age>20 Then (MessageRequester("Result","It's your shout for a beer!"))
Code where If sometimes is followed by Then, and sometimes is not followed by Then, does not look cleaner to me than the code which is currently valid in PureBasic, where If is never followed by Then.diceman wrote:One petty thing I'm missing in PureBasic, now don't laugh, is the "If ... Then" Statement.
When there's just one line of consequence, "If ... Then" looks cleaner, plus you'll get another tool to structure your code.
Thanks again for pointing me to the location where I got my solution from. It might not seem like a big thing, but you just made me the 2nd happy man in the world (No.1 happiest man is the guy married to Kate Upton).BarryG wrote:viewtopic.php?t=20619
Code: Select all
Macro THEN_(code)
: code : EndIf
EndMacro
Code: Select all
;pseudo code
if a = b then c = 1
Code: Select all
;pseudo code
if a = b then
c = 1
endif
procedure.s iifs(check.b, whenTrue.s, whenFalse.s)
if check
procedureReturn whenTrue
else
procedureReturn whenFalse
endif
endProcedure
define a.s = iifs(bool(1 = 0), "true", "false")
Amen brother... Amen.Tenaja wrote:...I should have just embraced the language as it was for what it was.
That's also why I even avoid creating my own libs and modules for small basic functions and prefer to use the PB model system or keyboard automatic typer.Tenaja wrote:I used to use macros to make pb more like what I was accustomed to, back when I first started. I quit doing it before a year had passed. By the third year, I looked at some of my original code and wondered what the heck I was thinking. I look back and know I should have just embraced the language as it was for what it was.