--- title: "Text Component" slug: "text-component" updated: 2023-02-13T09:55:45Z published: 2023-02-13T09:55:46Z canonical: "help.pillir.io/text-component" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.pillir.io/llms.txt > Use this file to discover all available pages before exploring further. # Text Component The Text component consists of blocks that perform operations related to texts. They are as follows: ## Text The **Text** block can have a text or number within quotes(''). This is used to represent a string. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Text or Number | Text | ![image-1674466308824](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1674466308824.png) | ```javascript '' ``` | ## Comment This block adds a piece of comment in the code script. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Text or Number | Text | ![Comment](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/Comment.png) | ```javascript /** '' **/ ``` | ## Create Texts from Multiple Texts This block combines two or more texts to return a new text. It is similar to string concatenation where two or more texts are joined to form a new text. It can be done using independent variables or arrays. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or text or number for all of the input values | Text | ![CreateText](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/CreateText.png)![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620902890579.png) | ```javascript '' + '' or ['','','',''].join(''); ``` | ## Convert Text to Upper Case, Lower Case or Title Case This block converts a string value to UPPER CASE, lower case or Title Case based on selection. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or text Choose the type of text operation from the dropdown list | Text | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620902938624.png)![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620902954688.png) | ```javascript 'abc'.toUpperCase() 'abc'.toLowerCase() textToTitleCase('abc') ``` | ## Length This block takes a particular text input (String) and provides the length of the text as output. The length is displayed as an integer. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Text or variable | Length of text as integer | ![Length(1)](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/Length(1).png) | ```javascript 'abc'.length ``` | ## Append Text This block is used to append a text value to the declared variables. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | For input-1: Choose variable from dropdown list For input-2: Add Variable block or Text | Append text value to the variable | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620902996857.png) ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903014957.png) | ```javascript item += '' ``` | ## Find First or Last Occurrence of Text This block finds the first or last occurrence of a piece of text in a given variable with the help of the text index. The search is done either on the top-down approach or vice-versa. By identifying the index value, the text location is identified and displayed in the output. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | For input-1: Choose a variable from the dropdown list Choose the operation from the dropdown list For input -2: Text or variable | Number | ![firstlastoccur](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/firstlastoccur.png) | ```javascript { item = text.indexOf('abc'); } ``` | ## Get Char This block fetches a particular character or letter (letter #, letter # from end, first letter, last letter, random letter) for a string input. This block also finds the letter with the help of indexing. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or Text for input-1 Choose the search index type (# - index from the top, # from end - index from the bottom, first letter, last letter and random letter). Variable or number for input-2 | Returns character from given input-1 text for the given input-2 index. | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903143934.png) | ```javascript text.charAt(0) text.slice(-1).charAt(0) text.charAt(0) text.slice(-1) textRandomLetter(text) ``` | ## Print to Console This block is used to print a particular variable to the browser console log. The variable can be either a text or a number declared as a string. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or Text or Number | Print the value to console output. | ![PrintConsole](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/PrintConsole.png) | ```javascript console.log(''); ``` | ## Print This block is used to print a particular text in an alert window in the UI. The input can either be a text or a number declared as a string. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or Text or Number | Print the value to the popup window. | ![Print](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/Print.png) | ```javascript window.alert('Text'); ``` | ## Trim This block trims white spaces before, after and in between texts. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or Text, Choose the trim type (both sides - trim both sides white space, left side - trim only left side white space and right side trim only right side white space). | Returns text with white space trimmed. | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903270335.png) ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903289198.png) | ```javascript 'abc'.trim() 'abc'.replace(/^[\s\xa0]+/, '') 'abc'.replace(/[\s\xa0]+$/, '') ``` | ## Variable Functions The Variable Functions command the return values based on user requests. They return: character location, character code location, concatenated values, includes, index values, last index values, local comparison values and many other values. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Choose the type of function Variable or Text or number for all input fields | Returns Text or Character | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903323399.png) ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903349058.png) | ```javascript pillirFunctions. variable_function("charAt", "", "", "") ``` | ## Subtext This block is used to fetch a particular piece of text from the whole text(string). The inputs are given and the output is a character based on all the inputs. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Variable or Text for input-1 Variable or number for input-2 and input- 3 | Returns the Text from input-1 based on input-2 and input-3. | ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903402424.png) ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903459413.png) ![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1620903481429.png) | ```javascript text.slice(0, 1) ``` |