🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Bug that prevents you from using string blocks as an input in the or block

    Scheduled Pinned Locked Moved UiFlow 2.0
    3 Posts 2 Posters 2.1k Views
    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.
    • C Offline
      Colobro309
      last edited by

      I want to use the number and string blocks as inputs for the or and and blocks.
      0_1710990527180_82e084e5-f6d6-49e4-906f-58fb81ec7328-image.png

      dissyD 1 Reply Last reply Reply Quote 0
      • dissyD Offline
        dissy @Colobro309
        last edited by

        @colobro309 That isn't a bug, that's just how mathematics works.
        And/or are logical functions, they only take true/false as inputs and returns a true/false.
        Add/subtract are arithmetic functions, they only take numbers as inputs and returns a number.

        You will need to convert your string or number into a true/false value first.
        The "IF" block can do this as it returns true/false.
        Eg "If number=0 return false else return true"

        1 Reply Last reply Reply Quote 0
        • C Offline
          Colobro309
          last edited by Colobro309

          In python you can use strings with the or and and keywords. The program sends a TCP request and prints the response, but if it fails it prints connection error.

          def Send_TCP_Request():
            try:
              tcpc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
              tcpc.settimeout(1)
              tcpc.connect(('0.0.0.0', 8000))
              tcpc.send('Hello World')
              Result = tcpc.recv(1024)
              tcpc.close()
            except:
              Result = None
          
            return Result
          
          def setup():
            M5.begin()
            print(Send_TCP_Request() or "Connection Error")
          
          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post