Page 1 of 1

Keypad use in Flowcode

Posted: Wed Dec 17, 2008 3:08 pm
by Walbeek
Hi there,

I would like to read 3 numbers from the keyboard using the "GetKeypadNumber" macro.
I copy these 3 numbers into 3 variables at the moment, called digit1, digit2 and digit3.
I also copy the value of these digits into Eprom.

For my current project I need the 3 digits into one variable.
For example, 1, 3, 5 gives digit1 = 1, digit2 = 3, digit3 = 5.
I want to copy this into a variable, called total.
This should give total = 135. (or anything else between 0 and 255)
Is this possible, and how can I do this?
Please give me some tips on this subject.
Best regards, Rinie

Re: Keypad use in Flowcode

Posted: Wed Dec 17, 2008 5:33 pm
by Benj
Hello Rinie

Yes this should be quite simple to do. First you will have to convert the numbers from ASCII to plain numeric data (only do this step if you are using the ReadAsAscii function)

Calculation
digit1 = digit1 - '0'
digit2 = digit2 - '0'
digit3 = digit3 - '0'

Once you have done this you will need to create a variable to hold the result. You will have to use a INT variable here for any numbers over 255.

Calculation
total = digit3
total = total + (digit2 * 10)
total = total + (digit1 * 100)

Hope this helps. 8)