View Single Post
  #8  
Unread 04-08-2005, 10:21 PM
ger's Avatar
ger ger is offline
Steward of the Faithful
This person is a EQ2Map developer.
Interface Author - Click to view interfaces
 
Join Date: Nov 2004
Server: Antonia Bayle
Posts: 580
Default

Quote:
Originally Posted by Drumstix42
Hmmm... now to figure out && and || !
Keep in mind that

IF ((A == true) && (B == true)) { DoThis }

is the same as

IF (A == TRUE) { IF (B == true) { DoThis }}

and

IF ((A == true) || (B == true)) { DoThat }

is the same as

IF (A == true) { DoThat }
IF (B == true) { DoThat }

So while it isn't as efficient, we don't need to figure out how to use && and ||.

Edit: while the above would work for IF-THENs, IF-THEN-ELSEs get a bit more complicated. Examples:

For &&:

IF (A == true) { IF (B == true) { DoThis; DoneThis = true }}
IF !(DoneThis == true) { DoTheOther }

For ||:

IF (A == true) { DoThat; DoneThat = true }
IF (B == true) { DoThat; DoneThat = true }
IF !(DoneThat == true) { DoTheOtherOther }

Why do you need the exra flag/test for IF-THEN-ELSEs? The simple answer is that you can't tie it the ELSE to either of the individual IFs or they'll end up triggering when they shouldn't (one IF is false, the other isn't) or they won't trigger when they should (the wrong IF is false.) An example:

IF (A == true) { IF (B == true) { DoThis } ELSE { DoTheOther }}

will only trigger DoTheOther whe B isn't true, not when A isn't true as you'd want an && to.

IF (A == true) { IF (B == true) { DoThis }} ELSE { DoTheOther }

will only trigger DoTheOther when A isn't true, not when B isn't true as you'd want an && to.

IF (A == true) { DoThat } ELSE { DoTheOtherOther }
IF (B == true) { DoThat } ELSE { DoTheOtherOther }

will trigger DoTheOtherOther when either A or B aren't true, when we want it to trigger only if both A and B aren't true.

An alternate to flagging for &&:

IF (A == true) { IF (B == true) { DoThis } ELSE { DoTheOther}} ELSE { DoTheOther }

still not as efficient as a && would be, but it, too, will work.

(Please note that all of this is pseudo-code and would need to be massaged into several different chained objects to be used in an actual UI XML.)
__________________

Last edited by ger : 04-08-2005 at 10:58 PM.
Reply With Quote