logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    How to do logical AND in conditionals?

    Scheduled Pinned Locked Moved
    Help and Support
    3
    8
    219
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Deeeds
      last edited by

      If this AND that then jump

      ... how to do this in hyperPad?

      Aidan_FireA 1 Reply Last reply Reply Quote 0
      • Aidan_FireA
        Aidan_Fire @Deeeds
        last edited by

        @Deeeds Have an If stacked on top of another If. The more conditions you have, the longer your If chain is.

        1 Reply Last reply Reply Quote 0
        • Aidan_FireA
          Aidan_Fire
          last edited by Aidan_Fire

          0_1509858027335_C46BF54C-8EA6-41BB-97CB-00B8BE87BA9D.png

          D 1 Reply Last reply Reply Quote 1
          • D
            Deeeds @Aidan_Fire
            last edited by

            @Aidan-Oxley What about OR, XOR and NOT?

            Aidan_FireA Jack8680J 2 Replies Last reply Reply Quote 0
            • Aidan_FireA
              Aidan_Fire @Deeeds
              last edited by Aidan_Fire

              @Deeeds For Or, have the two Ifs next to each other underneath the event. I don’t know what XOR is. For not, press the “is equal to” when you tap the If behaviour, there will be a not equal to (≠).

              1 Reply Last reply Reply Quote 0
              • Aidan_FireA
                Aidan_Fire
                last edited by

                0_1509860759545_C98238C3-206F-41DF-980D-B976684252F0.png

                1 Reply Last reply Reply Quote 1
                • Jack8680J
                  Jack8680 @Deeeds
                  last edited by Jack8680

                  @Deeeds

                  (I'm going to use this to learn the code formatting on the forums)

                  Like Aidan said, (P AND Q) can be represented by nesting ifs. It can be done as

                  //# I'm not sure I fully get the syntax for comments
                  output = 0 //# default to 0 if they aren't both true
                  if P == 1:
                      if Q == 1
                          output = 1 //# set to 1 if they are both true
                  return output
                  

                  P OR Q:

                  output = 1 //# defaults to 1
                  if P == 0
                      if Q == 0
                          output = 0 //# if NOT(P) AND NOT(Q) is true, return 0
                  return output
                  

                  (P XOR Q) is the equivalent to ((P OR Q) AND NOT(P AND Q)), but there's an easy shortcut in that it's true when P ≠ Q:

                  output = 0
                  if P != Q:
                      output = 1
                  return output
                  

                  Edit: oh yeah, NOT P:

                  output = 1
                  if P = 1
                      output = 0
                  return output
                  

                  Edit 2: As hyperPad behaviours:
                  0_1509869001029_IMG_0361.PNG

                  D 1 Reply Last reply Reply Quote 2
                  • D
                    Deeeds @Jack8680
                    last edited by

                    @Jack8680 INCREDIBLE!!!

                    THANK YOU!!!!!!!

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post