[Done] No evaluation stop during AND and OR statements

All bugs related to new C backend
User avatar
STARGÅTE
Addict
Addict
Posts: 1615
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

[Done] No evaluation stop during AND and OR statements

Post by STARGÅTE »

Normally the evaluation stops, when a false occurs during And or a true occurs during Or.
This isn't anymore in the C-backend, resulting in lots of errors in larger codes.

Code: Select all

Procedure Less(A, B)
	Debug Str(A) + " < " + Str(B)
	If A < B
		ProcedureReturn #True
	Else
		ProcedureReturn #False
	EndIf
EndProcedure


If Less(1, 0) And Less(3, 4)
	Debug "True"
Else
	Debug "False"
EndIf


If Less(0, 1) Or Less(5, 4)
	Debug "True"
Else
	Debug "False"
EndIf
PB 5.73 output:
1 < 0
False
0 < 1
True
PB 6.00 output:
1 < 0
3 < 4
False
0 < 1
5 < 4
True
PB 5.73 ― Win 10, 20H2 ― Ryzen 9 3900X ― Radeon RX 5600 XT ITX ― Vivaldi 4.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
Fred
Administrator
Administrator
Posts: 14412
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: No evaluation stop during AND and OR statements

Post by Fred »

I overlooked this case and it's a pain to fix unfortunately. I will need to go back to drawing board to find a solution.
User avatar
Rings
Moderator
Moderator
Posts: 1403
Joined: Sat Apr 26, 2003 1:11 am

Re: No evaluation stop during AND and OR statements

Post by Rings »

just a hint,

in vb.net(and a lot of other languages) you can use
the keywords:

"AndAlso"
"OrElse"

in binary compare.

If the first condition before the "AndAlso" or "OrElse" is true,
all conditions behind "AndAlso" or "OrElse" will not been executed.
that would match PB's behaviour .
And is a nice and readable feature too.
SPAMINATOR NR.1
User avatar
mk-soft
Addict
Addict
Posts: 3191
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: No evaluation stop during AND and OR statements

Post by mk-soft »

There is a problem with conditional queries that can only be executed if the first condition is true.

Code: Select all

If OpenWindow(0, 5, 5, 200, 120, "Test C-BackEnd", #PB_Window_SystemMenu)
  
  If IsGadget(1) And GetGadgetState(1)
    Debug "Ok"
  Else
    Debug "Error"
  EndIf
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        Break
        
    EndSelect
  ForEver
  
EndIf
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Re: No evaluation stop during AND and OR statements

Post by cas »

Fred
Administrator
Administrator
Posts: 14412
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: No evaluation stop during AND and OR statements

Post by Fred »

Fixed.
Post Reply