Author Topic: [Solved] Cut a string  (Read 3347 times)

0 Members and 1 Guest are viewing this topic.

Offline Axenntio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 41
  • Rating: +3/-0
    • View Profile
[Solved] Cut a string
« 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
« Last Edit: June 09, 2014, 11:41:56 am by Axenntio »

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Cut a string
« Reply #1 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)).
« Last Edit: April 26, 2014, 08:33:41 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Axenntio

  • LV3 Member (Next: 100)
  • ***
  • Posts: 41
  • Rating: +3/-0
    • View Profile
Re: Cut a string
« Reply #2 on: April 26, 2014, 09:25:56 am »
Thank you a lot Hayleia, and thank you for the optimisation hint :)