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

List set index

Block is used for inserting/setting elements to the list data type. Left part defines the source variable of the list type.

Method of insertion:

  • set: sets a specific element to a new value,
  • insert at: inserts new value to the element on a specific position.

Then the selection of the new element position follows:

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

Entered value is connected from the right side.

Block XML representation

XML representation of lists_set_index block

<xml xmlns="http://www.w3.org/1999/xhtml">
  <block type="lists_set_index">
    <mutation at="true"/>
    <field name="MODE">SET</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>
    <value name="TO">
      <block type="text">
        <field name="TEXT">value</field>
      </block>
    </value>
  </block>
  <block type="lists_set_index">
    <mutation at="true"/>
    <field name="MODE">INSERT</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>
    <value name="TO">
      <block type="text">
        <field name="TEXT">value</field>
      </block>
    </value>
  </block>
  <block type="lists_set_index">
    <mutation at="false"/>
    <field name="MODE">SET</field>
    <field name="WHERE">FIRST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
    <value name="TO">
      <block type="text">
        <field name="TEXT">value</field>
      </block>
    </value>
  </block>
  <block type="lists_set_index">
    <mutation at="false"/>
    <field name="MODE">INSERT</field>
    <field name="WHERE">LAST</field>
    <value name="VALUE">
      <block type="variables_get">
        <field name="VAR">list</field>
      </block>
    </value>
    <value name="TO">
      <block type="text">
        <field name="TEXT">value</field>
      </block>
    </value>
  </block>
</xml>

Example of visual representation

Block "List set index"

Block “List set index”

Example of block usage

Example of "List set index" block

Example of “List set index” block

Block is used on the “in list” rows in the example:

  • New variable list of the list data type with elements “item1” and “item2” is created.
  • Value “item3” is entered on the first position on the “in list” row.
  • Value “item_set” is entered on the second position is entered on the next “in list” row.

List containing values = [“item3”, “item_set”, “item2”] is the result of the program.

Processing result

Results of "List set index" block

Results of “List set index” block