π
<-
Chat plein-écran
[^]

split strings into characters

Pour le TI-Basic sur Nspire

split strings into characters

Message non lude 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
Avatar de l’utilisateur
BluStar
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 68%
 
Messages: 9
Inscription: 27 Jan 2022, 10:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: split strings into characters

Message non lude 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: Tout sélectionner
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
Avatar de l’utilisateur
SlyVTTPremium
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Prochain niv.: 43.1%
 
Messages: 484
Images: 31
Inscription: 19 Jan 2021, 09:41
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
GitHub: SlyVTT

Re: split strings into characters

Message non lude BluStar » 27 Jan 2022, 11:23

Thanks
Avatar de l’utilisateur
BluStar
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 68%
 
Messages: 9
Inscription: 27 Jan 2022, 10:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile


Retourner vers Nspire-Basic

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 21 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1268 utilisateurs:
>1245 invités
>18 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)
cron