[Implemented] BoolEval() or EvalBool() Command

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Grunz
User
User
Posts: 59
Joined: Sat Nov 12, 2011 7:21 pm

[Implemented] BoolEval() or EvalBool() Command

Post by Grunz »

Implemented as Bool()

Id like to be able to calculate boolean expression outside of "If","While" and similar.
So that the result may be assigned to a variable or given as parameter.

examples:

Code: Select all

result1.b = BoolEval( a > b )

result2.b = BoolEval(a$ = b$)
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: BoolEval() or EvalBool() Command

Post by luis »

http://www.purebasic.fr/english/viewtop ... 31#p303631

in the meantime this still works

Code: Select all

Macro Bool (exp)
; Evaluate an expression as a boolean.
;
; a = 15
; Debug (a = 15)      ; prints 15
; Debug Bool(a = 15)  ; prints 1 (#True)

 (1 And (exp))
EndMacro


a = 15
b = 10

result1 = Bool( a > b )
Debug result1

a$="test"
b$="best"

result2 = Bool(a$ = b$)
Debug result2
"Have you tried turning it off and on again ?"
A little PureBasic review
Post Reply