Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Axenntio on April 08, 2014, 09:01:32 am
-
Hi dear community ! :D
Since 1 days, I program a music editor in Axe, and I need to write the number of the line BUT, I want customs numbers:
[E0A0A0A0E00000004040404040000000E020E080E0000000E020E020E0000000A0A0E02020000000E080E020E0000000E080E0A0E0000000E0A0202020000000E0A0E0A0E0000000E0A0E020E0000000]->Pic0
Where is the problem ? I want separate all the part of the number: so for 125 I can have 1, 2 and 5
The number 125 is stored in the var L
After, I want display the number with:
Pt-On(2,I*6+2(,the 100th terme of M)*8+Pic0
Pt-On(6,I*6+2,(the 10th terme of M)*8+Pic0
Pt-On(10,I*6+2,(the 1st terme of M)*8+Pic0
Can you help me ? :/
-
Ah, you want to get the decimal digits out of a number :D
The modulo operator (^) does exactly that for you. It returns the remainder of a division. Say 27/10 is 2 remainder 7, so 27^10 returns 7. There you have the first digit (units), then you divide the number by ten and do it again for the tenths and so on.
125->M
Pt-On(10,I*6+2,M^10*8+Pic0) //units
Pt-On(6,I*6+2,M/10->M^10*8+Pic0) //tenths
Pt-On(2,I*6+2,M/10^10*8+Pic0) //hundreds
The original value of M is corrupted, you might want to save that before the calculation
-
How do I exactly forgotten the modulo... Ha... because I know it like (%)... Thank you a lot MGOS, Topic solved :3
-
For even more flexibility you should use a for loop. But that's up to you. :P
-
Here is a full code I quickly (as you can tell from the sprites) threw up as an example.
.AA
..Main Code
ClrDraw
Print(45125)
DispGraph
While 1
EndIf getKey(15)
Return
..Routines
Lbl Print
88
For(4)
Select(,sub(Print1))-8
End
Lbl Print1
Pt-Off(,20,r1^10*8+°Nb)
r1/10->r1
Return
..Data
[]->°Nb
[007CC4C642663C00]
[0008080808080800]
[003C260303063C06]
[003C04043C2C0C38]
[103060C0F8080808]
[003EE0C07C040CF8]
[041C306078683C18]
[007E02021F1C3060]
[7E466C78584C741C]
[70D8D8780808F800]
And here is what it outputs
(http://img.ourl.ca/cutvar.png)
Change the "88" and the "20" to change the coordinates of the number. Note that "88" is the X-coordinate of the last number. You can also add a "If r1" in the "Lbl Print" to have the routine not show useless zeroes.