Text get char at location
This block is used to get one character from arbitrary string. Left inner side defines the source string.
Right inner side defines the 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 the source string for operations and the second argument specifies the index in string.
The output of the block is one character from a specific position in the string. The position number is an integer value.
In case of usage of a 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 etc.) block returns value of None. In case the first argument is not a string value, the block returns None.
First letter is on position 0. So in the string “abcd”, letter “a” is on position “0” and letter “d” is on position “3”.
XML representation of the text_char_at 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>

Block “Text get char at location”

Example of “Text get char at location” block

Results of “Text get char at location” block