Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Axenntio on April 08, 2014, 09:01:32 am

Title: [Solved] Cut the numbers of a variable
Post 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:

Code: [Select]
[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:
Code: [Select]
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 ? :/
Title: Re: Cut the numbers of a variable
Post by: MGOS on April 08, 2014, 09:48:17 am
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.
Code: [Select]
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

Title: Re: Cut the numbers of a variable
Post by: Axenntio on April 08, 2014, 09:54:24 am
How do I exactly forgotten the modulo... Ha... because I know it like (%)... Thank you a lot MGOS, Topic solved :3
Title: Re: [Solved] Cut the numbers of a variable
Post by: Streetwalrus on April 08, 2014, 11:31:23 am
For even more flexibility you should use a for loop. But that's up to you. :P
Title: Re: [Solved] Cut the numbers of a variable
Post by: Hayleia on April 08, 2014, 01:59:37 pm
Here is a full code I quickly (as you can tell from the sprites) threw up as an example.

Code: [Select]
.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.