In the C language the logical AND operator (&&) returns the boolean value true if both operands are true and returns false otherwise. In PB the AND operator does the same thing.
enabled.b = #False
result = CallFunction(Lib, "SomeFunction) AND enabled
don't return the same result. So why would this happen? Isn't the PB function version 'result = CallFunction(Lib, "SomeFunction) AND enabled' the same as the C++ version in doing this?
Kaeru Gaman wrote:Boolean Expressions are NOT implemented in PB.
it's not possible to calculate boolean values.
it's an already requested feature, but it's not clearly said if it will ever be implemented.
@Derek - your right I think, but looking below your post...
@Kaeru - Ahhhhh...Ok then, there is the answer. But it is possible to evaluate boolean expressions. So then your saying that replacing the C++ '&&' with the PB 'AND' is not the same then?
is a Boolean calculation and they are just not implemented in PB.
so maybe sometimes you'll get the right result, but sometimes not and there is no guarantee for nothin'
is a Boolean calculation and they are just not implemented in PB.
so maybe sometimes you'll get the right result, but sometimes not and there is no guarantee for nothin'
is a Boolean calculation and they are just not implemented in PB.
so maybe sometimes you'll get the right result, but sometimes not and there is no guarantee for nothin'
I'm not arguing that they are not implemented, just the fact that if they were and you ANDed a boolean result with false then you would always get false as the answer which is of no use to anyone, you should AND with true and then you can get a true or false answer.
enabled = #False ; a 0
result = CallFunction(Lib, "SomeFunction) ; could be >0 or a 1 or a 0
If enabled = #False And result = 0 ; or even result <> 0, or maybe result >0
Debug "Yipee"
EndIf
be the same as:
[CODE B][/quote]
exactly, and that is the way you can do it in PB.
but you cannot calculate a result out of conditions, because
[b]Boolean Expressions and Boolean Calculations are not supported in PureBASIC[/b]
it's not a question of what i prefer, i would like to use them, but it is simply not implemented.
PS:
[quote="Derek"]... if they were ...[/quote]
if they were implemented you were right. I wish you were. :wink:
Ahhhh...OK then. I guess I was confusing 'evaluating' the expression with 'calculating the result' of an expression. They are not the same...well at least we can evaluate in some fashion, its something, but it would be really nice if PB had Boolean Expressions and Boolean Calculations.
I wonder why they haven't been implemented in PB yet? Would it be to difficult to do so in terms of a major shift in the fundamental way PB is implemented now? I wonder if it would be too difficult to build something like an add on library that would do it?
Last edited by SFSxOI on Mon Jan 29, 2007 3:51 pm, edited 1 time in total.
SFSxOI wrote:I wonder why they haven't been implemented in PB yet? Would it be to difficult to do so in terms of a major shift in the fundamental way PB is implemented now? I wonder if it would be too difficult to build something like an add on library that would do it?