🤖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

    UiFlow 2.0
    2
    3
    1.0k
    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
      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
        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
          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
          • First post
            Last post