User Manual
Print

Doing Actions when Taking Value in the Length of Array

For element value of list

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>index</variable><variable>value</variable><variable>list</variable></variables><block type=\"pxt_controls_for_of\" disabled=\"true\" x=\"23\" y=\"472\"><value name=\"VAR\"><shadow type=\"variables_get_reporter\" disabled=\"true\"><field name=\"VAR\">value</field></shadow></value><value name=\"LIST\"><shadow type=\"variables_get\" disabled=\"true\"><field name=\"VAR\">list</field></shadow></value></block></xml>"}
				
			

This block is used to do some actions when taking value in the array one by one until the end of list.

Parameters: 

      • Value
      • Array

Output: N/A
Sample code:

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>list</variable><variable>value</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">list</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"lists_create_with\"><mutation items=\"3\" horizontalafter=\"3\"/><value name=\"ADD0\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow></value><value name=\"ADD1\"><shadow type=\"math_number\"><field name=\"NUM\">1</field></shadow></value><value name=\"ADD2\"><shadow type=\"math_number\"><field name=\"NUM\">2</field></shadow></value></block></value><next><block type=\"pxt_controls_for_of\"><value name=\"VAR\"><shadow type=\"variables_get_reporter\"><field name=\"VAR\">value</field></shadow></value><value name=\"LIST\"><block type=\"variables_get\"><field name=\"VAR\">list</field></block></value><statement name=\"DO\"><block type=\"basic_consoleLogText\"><value name=\"text\"><shadow type=\"text\"><field name=\"TEXT\">It will repeat 3 times.</field></shadow></value></block></statement></block></next></block></statement></block></xml>"}
				
			

The output:

For Element Value of List - Output