π
<-
Chat plein-écran
[^]

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):

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 nSpireMagic Light for nSpire CX/CX-IIMagic Light for Casio Graph 90+ESimple Text Editor for nSpireOutRun for Casio Graph 90+E
95%
100%
100%
75%
100%
And more to come ... stay tuned
User avatar
SlyVTTPremium
Niveau 11: LV (Légende Vivante)
Niveau 11: LV (Légende Vivante)
Level up: 61.9%
 
Posts: 307
Images: 16
Joined: 19 Jan 2021, 09:41
Gender: Male
Calculator(s):
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):


Return to Nspire-Basic

Who is online

Users browsing this forum: No registered users and 4 guests

-
Search
-
Social
-
Featured topics
Reprise de ton ancienne fx-92 Collège ou Graph 25/35/90 à 5€. Même non fonctionnelle ou ancien modèle. Etiquette de retour fournie, pas de frais de port à payer.
Coque NumWorks édition limitée Mai 2022 à gagner.
Comparaisons des meilleurs prix pour acheter sa calculatrice !
123
-
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.
717 utilisateurs:
>668 invités
>44 membres
>5 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)