Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
hyperPad

hyperPad Forum

  1. Home
  2. Help and Support
  3. What's the best way to check if input is not a number

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

Scheduled Pinned Locked Moved Help and Support
18 Posts 5 Posters 4.0k Views 3 Watching
  • 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.
  • Aidan_FireA Aidan_Fire

    @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 Offline
    KamdroidK Offline
    Kamdroid
    wrote on last edited by
    #7
    This post is deleted!
    1 Reply Last reply
    0
    • KamdroidK Offline
      KamdroidK Offline
      Kamdroid
      wrote on last edited by Kamdroid
      #8

      @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

      Michael KhalfinG 1 Reply Last reply
      0
      • KamdroidK 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

        Michael KhalfinG Offline
        Michael KhalfinG Offline
        Michael Khalfin
        wrote on last edited by
        #9

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

        1 Reply Last reply
        0
        • iTap DevelopmentI iTap Development

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

          Aidan_FireA Offline
          Aidan_FireA Offline
          Aidan_Fire
          wrote on last edited by Aidan_Fire
          #10

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

          Jack de WildeJ 1 Reply Last reply
          0
          • Aidan_FireA Aidan_Fire

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

            Jack de WildeJ Offline
            Jack de WildeJ Offline
            Jack de Wilde
            wrote on last edited by
            #11

            @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
            0
            • Jack de WildeJ Jack de Wilde

              @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 Offline
              Aidan_FireA Offline
              Aidan_Fire
              wrote on last edited by Aidan_Fire
              #12

              @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
              0
              • iTap DevelopmentI 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 Offline
                iTap DevelopmentI Offline
                iTap Development
                wrote on last edited by
                #13

                @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
                0
                • KamdroidK Offline
                  KamdroidK Offline
                  Kamdroid
                  wrote on last edited by
                  #14

                  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
                  1
                  • Aidan_FireA Offline
                    Aidan_FireA Offline
                    Aidan_Fire
                    wrote on last edited by
                    #15

                    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
                    0
                    • Aidan_FireA Aidan_Fire

                      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 Offline
                      iTap DevelopmentI Offline
                      iTap Development
                      wrote on last edited by
                      #16

                      @aidan-oxley 🤣

                      1 Reply Last reply
                      0
                      • iTap DevelopmentI Offline
                        iTap DevelopmentI Offline
                        iTap Development
                        wrote on last edited by
                        #17

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

                        Aidan_FireA 1 Reply Last reply
                        0
                        • iTap DevelopmentI iTap Development

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

                          Aidan_FireA Offline
                          Aidan_FireA Offline
                          Aidan_Fire
                          wrote on last edited by
                          #18

                          @itap-development Yeah.

                          1 Reply Last reply
                          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
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Search