Hi to all.
how can I split a string into single characters?
For instance:
"Hello" in
"H"
"e"
"l"
"l"
"o"
Thanks
split strings into characters
3 posts
• Page 1 of 1
-
BluStar
Niveau 3: MH (Membre Habitué)- Posts: 9
- Joined: 27 Jan 2022, 10:12
- Gender:
- Calculator(s):→ MyCalcs profile
Re: split strings into characters
Hello,
you need to iterate through the length of the string and extract each of the character to print it.
This is a short program that do the stuff, but you will need to adjust as per your actual need:
So first we put the string in the variable str0 and put the length of str0 into the variable b using the dim() function.
Then we iterate through the string with the For loop. At each step, we extract the i-th character with the function mid() and draw the char with Disp.
Not so hard, just need to know the right functions to be used
Ciao
Sly
you need to iterate through the length of the string and extract each of the character to print it.
This is a short program that do the stuff, but you will need to adjust as per your actual need:
- Code: Select all
Define stringsplit()=
Prgm
"Hello"->str0
dim(str0)->b
For i,1,b
mid(str0,i,1)->ch
Disp ch
EndFor
EndPrgm
So first we put the string in the variable str0 and put the length of str0 into the variable b using the dim() function.
Then we iterate through the string with the For loop. At each step, we extract the i-th character with the function mid() and draw the char with Disp.
Not so hard, just need to know the right functions to be used
Ciao
Sly
Some works in progress :
The GUI Toolkit NF for nSpire | MyShmup for fxCG-50 | Magic Light for Casio Graph 90+E and Magic Light for nSpire CX/CX-II | Simple Text Editor for nSpire | OutRun for Casio Graph 90+E |
And more to come ... stay tuned
-
SlyVTTPremium
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 526
- Images: 32
- Joined: 19 Jan 2021, 09:41
- Location: France
- Gender:
- Calculator(s):→ MyCalcs profile
- GitHub: SlyVTT
-
BluStar
Niveau 3: MH (Membre Habitué)- Posts: 9
- Joined: 27 Jan 2022, 10:12
- Gender:
- Calculator(s):→ MyCalcs profile
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: ClaudeBot [spider] and 0 guests