Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Axenntio on April 26, 2014, 08:12:03 am

Title: [Solved] Cut a string
Post by: Axenntio on April 26, 2014, 08:12:03 am
I dear community ! :)

I exposed my problem...
I've a string like this: "Select1 Select2 Select3"->Str0

And I want disp it like this:

Select1
Select2
Select3

the next line is placed all the 8 char.

I've try this but... the code doesn't work exactly...

Code: [Select]
For(I,0,2)
Text(0,6*I,I*8+Str0)
End

Can you help me ?

Thanks you :)
#Axenntio
Title: Re: Cut a string
Post by: Hayleia on April 26, 2014, 08:27:34 am
If you don't mind changing your structure a bit, you can do that:
"Select1"[00]"Select2"[00]"Select3"[00]→Str0
For(I,0,2)
Text(0,6*I,stdDev(Str0,I))
End

This works even if your part strings are not the same length (like "A"[00]"BBBBB"[00]"CC"[00]).
(Runer112 pointed out on IRC that you can just use your code with my data and forget about stdDev if you keep them the same length).

If you do mind about keeping your structure (with spaces), you can just use a Copy before Text:
For(I,0,2)
Copy(I*8+Str0,L1,8)
Text(0,6*I,L1)
End


Now, about basic optimizations, you can write I*6 instead of 6*I and write your loop without an official loop variable (like a For(3)).
Title: Re: Cut a string
Post by: Axenntio on April 26, 2014, 09:25:56 am
Thank you a lot Hayleia, and thank you for the optimisation hint :)