Logmanager documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Text get char at location

Block is used to get one character from arbitrary string. Left inner side defines source string.

Right inner side defines type of value lookup direction:

  • letter #: gets character from position x from the start of the string,
  • letter # from end: gets character from position x from the end of the string,
  • first letter: gets first character from the start of the string,
  • last letter: gets last character from the end of the string.

Block accepts two arguments and both are required. First argument specifies source string for operations and second argument specifies index in string.

Output of the block is one character from a specific position in the string. Position number is integer value.

In case of usage of negative number, position from the end of the string is loaded. If the position is not found (position number is greater than length of string e.t.c) block returns value of None. In case first argument is not string value block returns None.

First letter is on position 0. So in string “abcd” letter “a” is on position “0” and letter “d” is on position “3”.

Block XML representation

XML representation of text_chatAt block:

<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="text_char_at">
    <mutation at="true"/>
    <field name="WHERE">FROM_START</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">text</field>
      </block>
    </value>
    <value name="AT">
      <block type="math_number">
        <field name="NUM">2</field>
      </block>
    </value>
  </block>
  <block type="text_char_at">
    <mutation at="true"/>
    <field name="WHERE">FROM_END</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">text</field>
      </block>
    </value>
    <value name="AT">
      <block type="math_number">
        <field name="NUM">2</field>
      </block>
    </value>
  </block>
  <block type="text_char_at">
    <mutation at="false"/>
    <field name="WHERE">FIRST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">text</field>
      </block>
    </value>
  </block>
  <block type="text_char_at">
    <mutation at="false"/>
    <field name="WHERE">LAST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">text</field>
      </block>
    </value>
  </block>
</xml>

Example of visual representation

Block "Text get char at location"

Block “Text get char at location”

Example of block usage

Example of "Text get char at location" block

Example of “Text get char at location” block

Processing result

Results of "Text get char at location" block

Results of “Text get char at location” block