Partial If with Or

Everything else that doesn't fall into one of the other PB categories.
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Partial If with Or

Post by jacdelad »

Hello,
I know that if I write something like

Code: Select all

If 1 And 0 And 1
PureBasic stops after the "0", which makes sense.

But what if I write

Code: Select all

If 1 Or 0
Does it apply for Or, too? I know, that it won't stop, even if the first value is a "0", but would

Code: Select all

If simple Or (ComplexFunction()1 And ComplexFunction2())
be faster than

Code: Select all

If (ComplexFunction()1 And ComplexFunction2()) Or simple
assuming that if simple is often #True and the two complex and time consuming functions aren't called at all?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Partial If with Or

Post by jacdelad »

I'm stupid. I tried:

Code: Select all

If 1 Or MessageRequester("","",0)
  Debug "No Messagebox -> shortened"
Else
  Debug "I'm never shown"
EndIf
...and it answered my question.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
Post Reply