How to add word count to your apps

In this tutorial we will look at how to use list blocks to create a simple word counting app.
Most word processors have a word count function, and there are other uses cases like limiting users to “100 words or less” for example.

Blocks

Even though we are working with text and words in this example, the majority of the blocks we will need are actually found in the Lists drawer.

list_blocks

The first thing you need to do is split your string (or sentence) up in to individual words. To do this we will use the make list from text block, but rather than using a comma as the delimiter we will use a space. This is done by changing the "," to just " ".
list_from_text

Now that all the words are stored in a list, we can count how many words there are by measuring the length of a list. This is done with the following block:

length_of

Putting it all together

Finally, we can create a word count label by putting everything together like so:

Hopefully you will be able to implement this for all your word-counting needs, let us know in the comments how you’ve used Word Count in your Thunkable Projects.

Thanks!

1 Like