List create
This section is available only in EnglishThis block is used to create variable with list data type. Output of the block is empty list of values.
This block is used to create a new list with defined elements. Option to insert more elements is under the “options” icon in the left part. Values are connected in the right part. Output of the block is a list with defined elements.
In case block has defined connection slots without assigned value None value is automatically generated into to fill empty connector to not break list indices. However this situation should be fixed.
XML representation of lists_create_with block
<xml xmlns="http://www.w3.org/1999/xhtml">
<block type="lists_create_with">
<mutation items="0"/>
</block>
<block type="lists_create_with">
<mutation items="3"/>
<value name="ADD0">
<block type="text">
<field name="TEXT">val1</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get">
<field name="VAR">var2</field>
</block>
</value>
<value name="ADD2">
<block type="logic_null"/>
</value>
</block>
</xml>
Block is used on the “set list to” row in the example:
- New variable “list” of a list data type with “item1” and “item2” elements is created.
- Value “item 3” is inserted to the first position in the list on the “in list” row.
- Value “item_set” is inserted on the second position on the next “in list” row.
Output of this program is a list containing values = [“item3”, “item_set”, “item2”].
Next example of “Create list with” block use consists in creation of names of input data keys. Values of all those keys gets IP address data type assigned.
{
"src_ip": "192.168.1.5",
"dst_ip": "8.8.8.8",
"remote_ip": "1.2.3.4",
"username": "administrator"
}