Partial If with Or

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

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?
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
User avatar
jacdelad
Addict
Addict
Posts: 2044
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

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.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply