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

List get index

This block is used to get/pop/delete value in list Left part defines the source list.

Block has several modes to obtain the element in the middle:

  • get: obtaining specific element,
  • get and remove: obtaining specific element and deleting it from the list,
  • remove: removing the element from the list.

Right part defines the element order:

  • #: defines specific order in the list,
  • # from end: defines specific order in the list, counted from the end,
  • first: value is entered as a first element of the list,
  • last: value is entered as a last element of the list.

In case of specified variable is not list or specified index can’t be found returns None.

Block XML representation

XML representation of lists_get_index blockĀ¶

<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="lists_get_index">
    <mutation statement="false" at="true"/>
    <field name="MODE">GET</field>
    <field name="WHERE">FROM_START</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
    <value name="AT">
      <block type="math_number">
        <field name="NUM">0</field>
      </block>
    </value>
  </block>
  <block type="lists_get_index">
    <mutation statement="false" at="true"/>
    <field name="MODE">GET_REMOVE</field>
    <field name="WHERE">FROM_END</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
    <value name="AT">
      <block type="math_number">
        <field name="NUM">0</field>
      </block>
    </value>
  </block>
  <block type="lists_get_index">
    <mutation statement="true" at="false"/>
    <field name="MODE">REMOVE</field>
    <field name="WHERE">FIRST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
  </block>
  <block type="lists_get_index">
    <mutation statement="true" at="false"/>
    <field name="MODE">REMOVE</field>
    <field name="WHERE">LAST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
  </block>
</xml>

Example of visual representation

Block "In list get"

Block “In list get”

Example of block usage

Example of "In list get" block

Example of “In list get” block

Block is used twice in the example:

  • Variable list contains 3 elements: item1, item2, item3.
  • In list remove removes the last element in the list. Variable list now contains 2 elements “item1” and “item2” as a result.
  • Second use of the “In list get” block loads first element of the list. Loading of “item1” element is the result.

Content of the “list1” key is visible in the processing result. This key should contain 3 elements of the list. Because the program works only with one object of the list variable, in this case list contains only values item1 and item2.

Processing result

Results of "In list get" block

Results of “In list get” block