Page 2 of 2
Re: #True is only 1, not all True
Posted: Mon Jan 04, 2010 12:47 am
by rsts
utopiomania wrote:#TRUE is a constant defined as NOT #FALSE. True can be anything as long as it is not false, and false
can be anything as long as it is not true.
Simple as that. :roll:
Code: Select all
Define condition
condition=6
If condition = #True
debug "Condition is #True"
EndIf
If condition NOT #False
debug "condition is NOT #False"
EndIf

Re: #True is only 1, not all True
Posted: Sun Jan 10, 2010 2:08 pm
by JackWebb
I was just thinking about this the other day while working on an IF structure. I have to agree with Mr. Gaman's original question. #False is always false it never changes. But #True is not always "true" but never false. This is what I came up with. I wonder if it will work in every case? Thanks to Idle for the tip!
Code: Select all
Macro IsTrue(v)
v Or 0
EndMacro
Macro IsFalse(v)
0 Not v
EndMacro
Test = 0
If IsTrue(Test)
Debug "test is true"
EndIf
If IsFalse(Test)
Debug "test is false"
EndIf
Jack
Re: #True is only 1, not all True
Posted: Sun Jan 10, 2010 4:05 pm
by Trond
Why go through all of that hassle when you can do it correctly like this:
Code: Select all
Test = 0
If Test
Debug "test is true"
EndIf
If Not Test
Debug "test is false"
EndIf
Re: #True is only 1, not all True
Posted: Mon Jan 11, 2010 5:21 pm
by Joakim Christiansen
Trond wrote:Why go through all of that hassle when you can do it correctly like this:
Code: Select all
Test = 0
If Test
Debug "test is true"
EndIf
If Not Test
Debug "test is false"
EndIf
+1
And maybe PB should get the keywords "true" and "false" too; so people wont mistake the constant for such...
Re: #True is only 1, not all True
Posted: Tue Jan 12, 2010 2:48 am
by JackWebb
Trond wrote:Why go through all of that hassle when you can do it correctly like this:
Code: Select all
Test = 0
If Test
Debug "test is true"
EndIf
If Not Test
Debug "test is false"
EndIf
Because pointless coding gymnastics force me to think about things I normally would not think about. Also because it helps a PureBasic noob like me gain a deeper understanding of the language. Other than that it's a good question and interesting to read everyone's reponses and code.
Jack