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

    What's the best way to check if input is not a number

    Scheduled Pinned Locked Moved
    Help and Support
    5
    18
    2.2k
    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.
    • iTap DevelopmentI
      iTap Development @Kamdroid
      last edited by iTap Development

      @kamdroid add 1 to the input and if the add outputs a 1 it’s text. If it isn’t 1 it is a number.

      Aidan_FireA 1 Reply Last reply Reply Quote 1
      • Aidan_FireA
        Aidan_Fire @iTap Development
        last edited by

        @itap-development Or it's zero 😜

        iTap DevelopmentI 1 Reply Last reply Reply Quote 0
        • Aidan_FireA
          Aidan_Fire @Kamdroid
          last edited by

          @kamdroid Picture of basically what @iTap-Development said, put into behaviours (except I'm using 0 rather than 1)
          0_1522793113825_50501114-B7B0-4F38-9660-56A1EA9B250E.jpeg

          KamdroidK 1 Reply Last reply Reply Quote 2
          • iTap DevelopmentI
            iTap Development
            last edited by iTap Development

            Just realized this won’t work if the input is already the number 0 though lol. You would still get the output of 1 (or 0).
            But another if would fix!

            iTap DevelopmentI 1 Reply Last reply Reply Quote 0
            • iTap DevelopmentI
              iTap Development @Aidan_Fire
              last edited by iTap Development

              @aidan-oxley NOOOOOOO!!! You have to use ONE! 🤨🤨🤨 🤪🤪🤪

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

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • KamdroidK
                  Kamdroid
                  last edited by Kamdroid

                  @iTap-Development @Aidan-Oxley Thank you, this is a nice solution.

                  edit: I just released my simple calculator, which is why I wanted to ask this question. https://www.hyperpad.com/projects/asudb1ye

                  GameCRAZYG 1 Reply Last reply Reply Quote 0
                  • GameCRAZYG
                    GameCRAZY @Kamdroid
                    last edited by

                    @kamdroid Cool, I will check it out because it sounds interesting!

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

                      @itap-development 🙄
                      0_1522847857495_F4C45EF1-DB27-4105-ACA7-A0BBEC30A71E.jpeg
                      EDIT: this does not work, use the other one somewhere above.

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

                        @aidan-oxley those first 2 ifs should be checking if it's zero, right? Because text+1 is the same as 0+1?

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

                          @jack8680 First it checks whether the value is the number 1 or not, if it is then it's done and it's a number. If it's not the number 1, then it adds 1 to it. If that result is 1, then it was text (since text will be treated as zero, so 0 + 1 = 1), if the result was not 1, then it is any number other than 1 (since 1 was already checked for at the start). I prefer adding 0 rather than 1 lol.

                          1 Reply Last reply Reply Quote 0
                          • iTap DevelopmentI
                            iTap Development @iTap Development
                            last edited by

                            @itap-development said in What's the best way to check if input is not a number:

                            Just realized this won’t work if the input is already the number 0 though lol. You would still get the output of 1 (or 0).
                            But another if would fix!

                            🤦‍♂️ just realized your first screen shot already did this... I’m stupid🤯

                            1 Reply Last reply Reply Quote 0
                            • KamdroidK
                              Kamdroid
                              last edited by

                              I thought the first if statements should check if it is 0, not 1, too.

                              If input was 0, 0+1 = 1, creating a false-positive to it being not a valid number.

                              If input was 1, and the if statements didn't exist, 1+1 = 2, this would say it is a valid number.

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

                                Ah ok, yeah the second one I made just to satisfy @iTap-Development's OCD wouldnt work, the first set of Ifs probably needed to stay as zero. Just use the one that adds zero lol.

                                iTap DevelopmentI 1 Reply Last reply Reply Quote 0
                                • iTap DevelopmentI
                                  iTap Development @Aidan_Fire
                                  last edited by

                                  @aidan-oxley 🤣

                                  1 Reply Last reply Reply Quote 0
                                  • iTap DevelopmentI
                                    iTap Development
                                    last edited by

                                    Whether you add 1 or 0 you still need all the ifs in both screen shots, right?

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

                                      @itap-development Yeah.

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