|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-03-2006 12:32
Where did I go wrong here: else if (message == "Add") { integer b = TRUE; integer m = TRUE; b = (llGetListLength(dest) > 20); m = (llGetFreeMemory() < 200); if (!b || m )// Tests to see if either statement is true { llOwnerSay("You can not add any more destinations"); } else { llOwnerSay("What do you want to name this destination?"); state adddest; } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
|
10-03-2006 12:38
From: Jesse Barnett Where did I go wrong here: if (!b || m )// Tests to see if either statement is true
Order of operation. that statement says literally "if 'not b' OR m" because OR is near the very bottom of operation chain ( http://www.lslwiki.com/lslwiki/wakka.php?wakka=operators) You can enforce correct order with: if( !( b || m ) ) ... or easier to read: if( (b == TRUE) || (m == TRUE) ) ...
|
|
Don Misfit
Registered User
Join date: 1 Jun 2006
Posts: 60
|
10-03-2006 13:06
Jesse --- While Joannah's explanation of Order of operation is correct, I think you have a logic error there... Your comment indicates that you are looking to see if "either statement is true," but the conditional: if ( !b || m ) is really saying: if b is FALSE OR if m is TRUE I think what you want is simply: if ( b || m ) // Tests to see if either statement is true
Don
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-03-2006 14:06
Thank you Don, Yep I played with it some and came up with: if ( !b || !m )
and it worked and then just I changed the TRUE's to FALSE's and changed "if" to the way you have it. Just took a little nudge and some brain exercise 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
de Morgan
10-03-2006 18:49
for what it is worth, (!a || !b) == !(a && b) and (a || b) == !(!a && !b) sometimes helps to use alternate version So ( !b || !m ) could become !(b && m ) and if you invert the if/else clauses you would use (b && m ) which is probably the easiest to follow
|