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



  • 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



  • @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"



  • 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")