8 Replies Latest reply on Apr 24, 2013 1:00 PM by GordonSmith

    Help with number

    fsoender

      I want to check for numbers in a "IF statement". Say if I got 0-10000 as a value, I want to only check for value between 1000-10000.

        • 1. Re: Help with number
          pauland Level 4

          Have a go at writing the if statement yourself, then show us.

           

          There must be thousands  of examples of how to use the if statement and write conditional expressions on the web.

          • 2. Re: Help with number
            fsoender Level 1

            Ok, thanks, but how can I add a letter "G" to check in a "IF stament"?

             

            I cant write this:

             

            if(NewValue < G50)

             

             

            So how can I fix it in this:

             

             

            public var NewValue:Object;

            public var Value:String;

             

             

            var Value:String = event.data.readUTFBytes(event.data.bytesAvailable);

               

                        if(Value)

                        {

                

                 NewValue = Value;   

                

                 if(NewValue < 50)

                 

                     

                 {     

                  Battery.setStyle("chromeColor", "red");

                       

                 }

                 

                

                 else     

                 {      

                  Battery.setStyle("chromeColor", "green");      

                 }

            • 3. Re: Help with number
              pauland Level 4

              I don't understand what you're trying to do and you're still using incorrectly named variables.

              • 4. Re: Help with number
                fsoender Level 1

                ok, I got a value "G100" comming in thru USART, I want to be able to read this in a "IF statement"

                 

                Something like this, but it wont allow me this since its a Object, and it needs to be a Object.

                 

                Is that better to understand?

                 

                 

                 

                public var newValue:Object;

                 

                if(NewValue < G100)

                 

                ....

                • 5. Re: Help with number
                  pauland Level 4

                  G100 is a string so what kind of comparison are you trying to do?

                  • 6. Re: Help with number
                    fsoender Level 1

                    I know its a String, but that wont work either.

                     

                    Get this error then:

                     

                    I just want to check if value "G100" is reached, then do something else...

                    Multiple markers at this line:

                    -Access of undefined property G100

                    -1120: Access of undefined property G100.

                     

                    • 7. Re: Help with number
                      pauland Level 4

                      I think I'll let someone braver than me try and help you.

                      • 8. Re: Help with number
                        GordonSmith Level 4

                        I will only try to answer the first question, because I couldn't understand the later questions.

                         

                        > I want to check for numbers in a "IF statement". Say if I got 0-10000 as a value, I want to only check for value between 1000-10000.

                         

                        if (1000 <= value && value <= 10000)

                         

                        - Gordon