Announcement

Collapse
No announcement yet.

variable long

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • variable long

    Hello and Happy New Year to all.

    someone can tell me if there is an existing code to retrieve a variable keyboard input phone types . in order to make a comparison with a value received by serial link.

    thanks

  • #2


    I think I need to explain myself.

    with a keyboard when you enter numbers one behind the other after it makes a number and not a number.

    is there a code already realized by one of you to say:

    first digit of the second number * 1 + * 10 + * 100 + third digit etc etc ....

    because being new in C I'm not too much to leave to write this ..

    thank you

    I'm not sure of the translation ...

    Comment


    • #3


      I think I need to explain myself.

      with a keyboard when you enter digit one behind the other after it makes a digit and not a number.

      is there a code already realized by one of you to say:

      first digit * 1 + the second number * 10 +third digi * 100 + etc etc ....

      because being new in C I'm not too much to leave to write this ..

      thank you

      I'm not sure of the translation ...

      Comment


      • #4


        Thierry,

        You have been 'new to C' on these forums for over 6 months now.

        If you have not been able pick up the rudiments of it now it is time to look in other areas.

        Perhaps a 'short couse' or 'adult education' or whatever they call those, generally free or low cost, evening courses in your area.

        Maybe also a good book on the topic to help reinforce what you will learn.

        To put what you have asked in a 'close to code' way.....

        (first digit & 0x0f) * 1 + (the second number & 0x0f) * 10 +(third digit & 0x0f) * 100 + etc etc ....

        Now this is because 0 = 0x30, 1 = 0x31, etc. so anding the character with 0x0f will turn it into a number.

        Again, please consider some education on the topic
        Mark

        Comment


        • #5


          hello

          thank you for your answer.

          doing this six months that I actually buy a ?lcd32, you should know that I do not work 24/24 hours of programming.

          if there are examples to answer my questions they are welcome.

          thank you.

          Comment


          • #6


            You have not explained anything about the data format you are reading from the external device,
            therefore it is very difficult to steer you in the correct direction.

            Are you reading asci characters 0-9 (eg 0x30,0x31,0x32....0x39) which is same as '0','1','2'.....'9'.
            Or are you reading packed 'words' containing 4 digits each, or 'bytes containing 2 digits each.

            There are many ways of packing/unpacking/rebuilding numbers, and the techniques to understand
            how to do this are similar for all languages - low level conversions.

            If you ask for an example such as:

            "I am reading the output of a digital multimeter, ascii format "1234" and need to convert the value to a signed integer"

            or

            "I am sending a 32bit number as 4 bytes and need to print it on the screen"

            If you need to represent even larger numbers, here is an interesting article.
            http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic

            Also, an interesting site that compares similar coding techniques across many different languages can be found here.
            http://rosettacode.org/wiki/Rosetta_Code

            We can try and help if you describe exactly what you need to do.
            Regards,
            Dave

            Comment


            • #7


              hello and thank you

              I just entered with a keyboard value that is not a string but a number.

              thank you

              Comment


              • #8


                Still dont know what you want to do, maybe this is a starting point.

                It should work for numbers up to 32767

                func getKval()
                var num, c;
                repeat
                c := serin(); // get serial
                if (c == 0x0D) break; // exit if 'ENTER' key
                if (c < '0' || c > '9') continue; // if its a number 0-9
                num *= 10; // multiply the accumulator by the base number
                num += (c&0x0F); // add the new digit
                gfx_MoveTo(30,30);
                print(n," "); // display the number
                forever
                return n;
                endfunc
                Regards,
                Dave

                Comment


                • #9


                  thank you

                  but I think I hurt my application says.

                  I created a keyboard phone with 12 buttons (0 to 9 valid clear)

                  I loaded the code

                  and when I compile it requires a sum subroutine I do not understand???

                  if there is an example of a window with keyboard input is what I want.


                  thank you see you soon

                  Comment


                  • #10


                    Sorry, I cannot help you.

                    I suggest you work your way through some examples so you can start to learn how to program.

                    There is an example program named SerialKepad.4DG

                    I suggest you start with it, I hope it is applicable to what you may be trying to achieve.
                    Regards,
                    Dave

                    Comment

                    Working...
                    X