More than

Just starting out? Need help? Post your questions and find answers here.
Electric Sheep
New User
New User
Posts: 4
Joined: Mon Oct 10, 2011 2:26 pm

More than

Post by Electric Sheep »

Can anybody tell me why the output is different when they look similar...

Code: Select all

a.i = 20
b.i = 30
Debug a  - (a > b) ; output is -10
Debug 20 - (20>30) ; output is 20
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: More than

Post by srod »

PB does not support this use of the logical operators.
I may look like a mule, but I'm not a complete ass.
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: More than

Post by luis »

You can maybe approximate what you wanted with this hack:

Code: Select all

Macro BOOL (exp)
; a = 15
; Debug (a = 15)      ; prints 15
; Debug BOOL(a = 15)  ; prints 1 (#True)

 (1 And (exp))
EndMacro


a.i = 20
b.i = 30
Debug a  - BOOL(a < b) ; 19
Debug a  - BOOL(a > b) ; 20
Debug 20 - BOOL(20 < 30) ; 19
Debug 20 - BOOL(20 > 30) ; 20
See also: http://www.purebasic.fr/english/viewtop ... 31#p303631
"Have you tried turning it off and on again ?"
Electric Sheep
New User
New User
Posts: 4
Joined: Mon Oct 10, 2011 2:26 pm

Re: More than

Post by Electric Sheep »

Thanks luis.

This seems to fix it...

Code: Select all

a.i = 20
b.i = 30
Debug a  - (a > b And 1) ; output is 20
Debug 20 - (20>30 And 1) ; output is 20
Post Reply