π
<-

split strings into characters

Pour le TI-Basic sur Nspire

split strings into characters

Unread postby BluStar » 27 Jan 2022, 10:18

Hi to all.
how can I split a string into single characters?
For instance:
"Hello" in
"H"
"e"
"l"
"l"
"o"

Thanks
User avatar
BluStar
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 9
Joined: 27 Jan 2022, 10:12
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: split strings into characters

Unread postby SlyVTT » 27 Jan 2022, 11:06

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:

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 nSpireMyShmup for fxCG-50Magic Light for Casio Graph 90+E
and
Magic Light for nSpire CX/CX-II
Simple Text Editor for nSpireOutRun for Casio Graph 90+E
95%
50%
100%
75%
100%
And more to come ... stay tuned
User avatar
SlyVTTPremium
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 46.2%
 
Posts: 526
Images: 32
Joined: 19 Jan 2021, 09:41
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
GitHub: SlyVTT

Re: split strings into characters

Unread postby BluStar » 27 Jan 2022, 11:23

Thanks
User avatar
BluStar
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Level up: 68%
 
Posts: 9
Joined: 27 Jan 2022, 10:12
Gender: Not specified
Calculator(s):
MyCalcs profile


Return to Nspire-Basic

Who is online

Users browsing this forum: ClaudeBot [spider] and 0 guests

-
Search
-
Social TI-Planet
-
Featured topics
Grand Concours 2024-2025 - Programmation Python
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
12345
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
924 utilisateurs:
>909 invités
>8 membres
>7 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)