Logmanager dokumentace
Přepnout tmavý/světlý/automatický režim Přepnout tmavý/světlý/automatický režim Přepnout tmavý/světlý/automatický režim Zpět na domovskou stránku

List get index

Tato sekce je dostupná pouze v angličtině.

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

The block has several modes to obtain the element in the middle:

  • get: obtaining a specific element,
  • get and remove: obtaining a 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 the specified variable is not a list or a specified index can’t be found, it returns None.

Block XML representation

XML representation of the 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

The block is used twice in the example:

  • Variable list contains 3 elements: item1, item2, item3.
  • 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, it only contains values item1 and item2.

Processing result

Results of "In list get" block

Results of “In list get” block