It was asked how you could capitalize 1st letter of every word in a sentence.
Below is a procedure that can take any sentence and will capitalize first letter of every word. For this, I have created a procedure-with-return called “capitalize”. The procedure accepts an argument “text”, performs some functions and then returns a result. This means we can invoke the procedure and pass it some Text data, and then expect it to return a result. When invoked, the “capitalize” procedure
- Initializes a global variable “varTemp”
- It then uses the “split at spaces” block to split the Text into pieces separated by spaces (i.e. splits into words). Once split, it will assign the List to “item” variable
- Next, we use a for-each block to loop through the newly created list of words. For each word,
- Using “segment” we extract 1st letter of the word and convert it to upper case
- Using “segment” we extract rest of the word starting 2nd position
- We join (i.e. concatenate) varTemp (see 1) + 3.i + 3.ii and add a blank space to the end
- Once the loop is completed, we use “trim” to get rid of last blank space and then return the result to the caller
Update above procedure to use local-variable instead of global. For purpose of tutorial, to keep blocks presentation simpler, global variable was used. Try to use a local-variable for the procedure.