PureBasic 4.50 is out !

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: PureBasic 4.50 is out !

Post 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.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: PureBasic 4.50 is out !

Post 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.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Frarth
Enthusiast
Enthusiast
Posts: 241
Joined: Tue Jul 21, 2009 11:11 am
Location: On the planet
Contact:

Re: PureBasic 4.50 is out !

Post 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.
PureBasic 5.41 LTS | Xubuntu 16.04 (x32) | Windows 7 (x64)
Post Reply