Page 6 of 6
Re: PureBasic 4.50 is out !
Posted: Wed Jul 14, 2010 9:31 pm
by Frarth
Thorium wrote:...because they are not supported outsite of if statements. So you should not use them in formulas at all.
I did use the '=' sign in my definition of a leap year, without the IF statement. For those just turning to PureBasic, that IS confusing.
Re: PureBasic 4.50 is out !
Posted: Thu Jul 15, 2010 9:58 am
by blueznl
With PureBasic working with boolean expressions is still very confusing. For example, this works:
Code: Select all
Procedure.i LeapYear(Year.i)
;returns:
; - True (1) If the given year is a leapyear
; - False (0) if the given year is not a leapyear
ProcedureReturn ((Year % 4) = 0) And ((Year % 100) <> 0) Or ((Year % 400) = 0)
EndProcedure
Debug LeapYear(2008)
Debug LeapYear(2009)
May it does work, but it is not supported AFAIK. What you're doing with the procedurereturn is just an alternative way to write this:
Original line:
Code: Select all
ProcedureReturn ((Year % 4) = 0) And ((Year % 100) <> 0) Or ((Year % 400) = 0)
Functional replacement:
Code: Select all
x = ((Year % 4) = 0) And ((Year % 100) <> 0) Or ((Year % 400) = 0)
ProcedureReturn x
Even if it (currently) works you should not do this, as it is not supported AFAIK.
Re: PureBasic 4.50 is out !
Posted: Thu Jul 15, 2010 4:35 pm
by Frarth
@ bleuznl, I was starting to wonder if I did the right thing with the LeapYear procedure while going through this topic. Normally I test things thoroughly, and if they work, I assume the compiler supports it. Obviously, that assumption is not correct. Thanks for pointing this out to me.