Is it possible to split a variable down by each digit?
This is a new one for me. I am trying to display different digits on 2 separate 7 segment displays. I have gotten most of it to work, but for some reason, when I pass the digit to be displayed and try to chop it down to display on the right segment, it shows a 1 or a 0 instead of the number I pass.
Here is a rough example on what i am trying to do :
digit = WORD
fdigit = WORD
sdigit = WORD
digit = 93
fdigit = digit.0
sdigit = digit.1
the output should be :
fdigit = 9
sdigit = 3
For some reason, I can't get the right output. Thanks for your help in advance!
Here is a rough example on what i am trying to do :
digit = WORD
fdigit = WORD
sdigit = WORD
digit = 93
fdigit = digit.0
sdigit = digit.1
the output should be :
fdigit = 9
sdigit = 3
For some reason, I can't get the right output. Thanks for your help in advance!
Comments
fdigit = digit / 10
sdigit = __remainder
You can now use these values to pull the appropriate segment maps from a table.
The reason your code is not working is that the dot notation of a variable is for bits (0 or 1), not decimal digits. BTW, you can use bytes instead of words to conserve RAM space.
[noparse][[/noparse]Edit] I modified the function to work around a divide by one bug in SX/B 1.51.03 and added a subroutine that will move the digits of a value to an array.
Post Edited (JonnyMac) : 7/6/2008 9:52:40 PM GMT