How do you separate a string into words from text box?

Hello all,

I am creating an app in which you have to enter a word or a sentence and it gives you the number each of the letters represents and the total amount. So far I can have the full output of the written sentence in the textbox, but I want first to have each of the words separated and then the full text, as seen in the pink picture- this is what I want to achieve.

In yellow - my current output: it just shows ¨HOLA MAMA¨ , and want it to divide the words HOLA and MAMA.

I am attaching my current blocks with which I can show the full text without showing each of the words separately.



You can separate text at a blank using the text block SPLIT AT SPACES.

The resulting list will have HOLA in item 1,
MAMA in item 2.

Show us your procedure if you need more help.

I can separate the words with split-at spaces, but I'm unsure how to bring each item separately.

The text is coming from the user input in a text box. Which blocks for ¨list¨ should I use?

Even if the user is inserting a text with 10 different words, how can I do it to bring each one of the words separately and then altogether?

Use "select list item" after split the text,

And join block to put together them.

thank you.

Is there any way I can do this automatically? for example, if the user inserts a sentence of 15 words, how can I code it to automatically divide each of the words and then put them together in one sentence at the end?

So far I can separate the words
using index, so for index 2, if I only have one word in textbox, it gives me an error that there is no index 2, ad so on .. .

Foe each item in list block can help you to use all the items generated after split the text.

You can also check the length of the generated list.

A different approach....

numbersFromWords.aia (3.9 KB)


(the text scrolls...)

Not quite sure why you want to show the sentence again ? (Or do you want to show the sentence as numbers and not letters?)

This seems good, will give it a try, thank you.

I need the full sentence again as it will have different sums in numbers.

Can you show a simple example of this ?


it should be some output like this.
First word, second word, and so on .... then the full sentence

Yes, I have done that part.

Do you want the full sentence in letters AND in numbers, with SUMA and LUPA values ?

Yes, exactly, the full sentence in letters AND in numbers, with SUMA and LUPA values. That would be good. Thanks a lot.

Try this:

numbersFromWords_rev2.aia (9.8 KB)

1 Like

Thank you very much for this, it is what I was looking for. Very much appreciated.

Just another last question, Do you know how can I add the amount of 30 for each of the letters and therefore the final suma and lupa to be 30+ in another different label, using the blocks given by you and still having the output from your blocks ?

In this case, for example, A would be 31, B - 32 and so on ...

This should do it:

2 Likes

This is great, thank you so much for the help. Already achieved what I needed.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.