Need help in array calculation
Need help in array calculation
Put data in array through keypad then combine it in integier variable. When i press 1234 the result is same 1234. But when i put 12 the result is 1200 insted of 12. Please help to solve this problem
- Attachments
-
- Flowcode1.fcf
- (13.5 KiB) Downloaded 163 times
- Steve
- Matrix Staff
- Posts: 3422
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: Need help in array calculation
One way is to perform the final calculation differently depending on the value of Key_COUNT.
For example, when Key_COUNT is 4 then "Result = Key_ADD[0] * 1000 + Key_ADD[1] * 100 + Key_ADD[2] * 10 + Key_ADD[3]" is correct.
But for Key_COUNT = 2, "Result = Key_ADD[0] * 10 + Key_ADD[1]".
Another way would be to keep a running total of the result as the keys are entered. Each time a new on is entered, the existing result needs to shift one decimal place and the new key result becomes the lowest digit.
For example, when Key_COUNT is 4 then "Result = Key_ADD[0] * 1000 + Key_ADD[1] * 100 + Key_ADD[2] * 10 + Key_ADD[3]" is correct.
But for Key_COUNT = 2, "Result = Key_ADD[0] * 10 + Key_ADD[1]".
Another way would be to keep a running total of the result as the keys are entered. Each time a new on is entered, the existing result needs to shift one decimal place and the new key result becomes the lowest digit.
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Need help in array calculation
Hi kg300, attached simplified flowchart might help.
The target device you are using will not have enough ram to compile either flowchart.
the * key is used to clear the result
The target device you are using will not have enough ram to compile either flowchart.
the * key is used to clear the result
- Attachments
-
- Flowcode1a.fcf
- (13 KiB) Downloaded 157 times
Martin