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
Keypad use in Flowcode
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Keypad use in Flowcode
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel