Skip to Content

String Manipulation Custom Blocks

A set of useful custom blocks to manipulate strings in Scratch.

I have put together a set of useful string manipulation custom blocks for Scratch. These blocks are based on the Left, Right, Mid, Upper and Lower commands you can find in BASIC and many other programming languages. The blocks I have implemented are:

  • Left(string, n) = Return the left most n characters of a string. e.g. Left("Scratch", 3) will return Scr
  • Right(string, n) = Return the right most n characters of a string. e.g. Right("Scratch", 3) will return tch
  • Mid(string, n, amount) = Return a specific amount of characters from a string. e.g. Mid("Scratch Programming", 9, 7) will return Program
  • ToUpperCase(string) = Return an upper case version of the string. e.g. ToUpperCase("scratch") will return SCRATCH
  • ToLowerCase(string) = Return a lower case version of the string. e.g. ToLowerCase("SCRATCH") will return scratch

I will be implementing some more custom blocks when time allows. The Scratch project can be found at scratch.mit.edu/projects/12402145/ and I have also put together a detailed blog post on the blocks and how to use them. The link for this is philcurnow.wordpress.com/2013/09/22/scratch-custom-string-blocks/ I hope you find these blocks useful and please feel free to use them in your projects. If you teach Scratch, you are more than welcome to use them as a teaching resource and share them around. If you would like to contact me about the blocks, leave a message on here, or you can tweet me @pcurnow.

Comments
Phil Curnow
Member
Thanks for the comment Susan. I have now implemented a String Search block. You can see this in the Scratch Demo and there is also a full discussion on my blog at http://philcurnow.wordpress.com/2013/11/16/string-search-in-scratch/
susan recoon
Member
How about parsing a string to search for a certain word?