Text Component
  • 13 Feb 2023
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Text Component

  • Dark
    Light
  • PDF

Article Summary

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.

InputOutputBlock LayoutGenerated Code
Text or NumberTextimage-1674466308824
''

Comment 

This block adds a piece of comment in the code script.

InputOutputBlock LayoutGenerated Code
Text or NumberTextComment
 /**
  ''
  **/

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.

InputOutputBlock LayoutGenerated Code
Variable or text or number for all of the input valuesTextCreateText
'' + ''

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.

InputOutputBlock LayoutGenerated Code

Variable or text

Choose the type of text operation from the dropdown list


Text
'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.

InputOutputBlock LayoutGenerated Code
Text or variableLength of text as integerLength(1)
'abc'.length

Append Text

This block is used to append a text value to the declared variables.

InputOutputBlock LayoutGenerated Code

For input-1: Choose variable from dropdown list

For input-2: Add Variable block or Text


Append text value to the variable 
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.

InputOutputBlock LayoutGenerated 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
{
   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.

InputOutputBlock LayoutGenerated 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.

text.charAt(0)

text.slice(-1).charAt(0)

text.charAt(0)

text.slice(-1)

textRandomLetter(text)

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.

InputOutputBlock LayoutGenerated Code
Variable or Text or NumberPrint the value to console output.PrintConsole
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.

InputOutputBlock LayoutGenerated Code
Variable or Text or NumberPrint the value to the popup window.Print
window.alert('Text');

Trim

This block trims white spaces before, after and in between texts.

InputOutputBlock LayoutGenerated 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. 
'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. 

InputOutputBlock LayoutGenerated Code

Choose the type of function

Variable or Text or number for all input fields


Returns Text or Character



 


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.

InputOutputBlock LayoutGenerated 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.


  
text.slice(0, 1)

Was this article helpful?

ESC

Eddy, a super-smart generative AI, opening up ways to have tailored queries and responses