I have the below code which is functional, but it bothers me that I can not think of a more elegant way to do what I want. I have a 6 digit 7 segment display that I am trying to us to manually set a long number with. The first 6 digits are the integer and the last 3 are for the decimal value, but it is treated as a long for all math and the decimal is just forced onto the end result for display purposes. Basically I have a flashing digit which I wish to increment with the LEFT button, the RIGHT button will go to the next digit and LEARN will save. When I roll over from 9 to 0 I do not want the value to be changed for any digit other than the one being adjusted. It seems like if I had a function that did the opposite of the DIG command I could just set individual digits.
Again, the code works, but it just seems like a waste of code space especially since I'm dealing with long math and I figured I might as well post here and see if anyone can come up with something more efficient.
Thanks for taking a look.Code:change_S_weight: if b = 0 then 'integer mode gosub display_S_Int gosub send_data pause 250 out_stream[temp2] = "_" 'flash digit GoSub send_data Pause 250 if right = 0 then 'move to next digit temp2 = temp2 + 1 if temp2 >= 6 then b = 1 temp2 = 0 endif endif if left = 0 then 'change the digt value if temp2 = 0 then weightl = weightl + 100000000 if weightl dig 8 = 0 then weightl = weightl -1000000000 endif if temp2 = 1 then weightl = weightl + 10000000 if weightl dig 7 = 0 then weightl = weightl -100000000 endif if temp2 = 2 then weightl = weightl + 1000000 if weightl dig 6 = 0 then weightl = weightl -10000000 endif if temp2 = 3 then weightl = weightl + 100000 if weightl dig 5 = 0 then weightl = weightl -1000000 endif if temp2 = 4 then weightl = weightl + 10000 if weightl dig 4 = 0 then weightl = weightl -100000 endif if temp2 = 5 then weightl = weightl + 1000 if weightl dig 3 = 0 then weightl = weightl -10000 endif endif else 'decimal point mode gosub display_S_DP gosub send_data pause 250 out_stream[temp2] = "_" 'flash digit GoSub send_data Pause 250 if right = 0 then 'move to next digit temp2 = temp2 + 1 if temp2 >= 3 then b = 0 temp2 = 0 endif endif if left = 0 then 'change the digt value if temp2 = 0 then weightl = weightl + 100 if weightl dig 2 = 0 then weightl = weightl -1000 endif if temp2 = 1 then weightl = weightl + 10 if weightl dig 1 = 0 then weightl = weightl -100 endif if temp2 = 2 then weightl = weightl + 1 if weightl dig 0 = 0 then weightl = weightl -10 endif endif endif IF learn = 0 Then GoTo save_S_weight GoTo change_S_weight
David




Bookmarks