使用手冊
Print

檢查檔案輸入是否多選

FileInput可以多選

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"Control_FileInput_isMultiple\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">fileInput</field></block></value></block></xml>"}
				
			

這積木是用作檢查有一個或多個檔案。

參數:螢幕項目(輸入控制:檔案輸入)

輸出: 螢幕項目

示例代碼:

結合其他邏輯積木如if-else條件積木。

				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"Control_FileInput_isMultiple\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">fileInput</field></block></value></block></value><statement name=\"DO0\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">count</field></block></value><value name=\"content\"><block type=\"text_join\"><mutation items=\"3\"/><value name=\"ADD0\"><shadow type=\"text\"><field name=\"TEXT\">There are </field></shadow></value><value name=\"ADD1\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow><block type=\"lists_length\"><value name=\"VALUE\"><block type=\"variables_get\"><field name=\"VAR\">gettingFile</field></block></value></block></value><value name=\"ADD2\"><shadow type=\"text\"><field name=\"TEXT\"> file(s).</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">count</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">Only one file is selected.</field></shadow></value></block></statement></block></xml>"}
				
			
				
					{"blocks":"<xml xmlns=\"https://developers.google.com/blockly/xml\"><variables><variable>mainLayout</variable><variable>mainScreen</variable><variable>fileInput</variable><variable>createButton</variable><variable>count</variable><variable>gettingFile</variable></variables><block type=\"pxt-on-start\" x=\"0\" y=\"0\"><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">mainLayout</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"ScreenItem_createLayout\"/></value><next><block type=\"variables_set\"><field name=\"VAR\">mainScreen</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Screen_create\"><value name=\"label\"><shadow type=\"text\"><field name=\"TEXT\">Main</field></shadow></value><value name=\"layout\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value></block></value><next><block type=\"variables_set\"><field name=\"VAR\">fileInput</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_createFileInput\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"1\" _input_init=\"true\"></mutation><field name=\"fileTypeFilter\">FileInputTypeFilter.None</field><value name=\"isMultiple\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">FALSE</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">fileInput</field></block></value><next><block type=\"variables_set\"><field name=\"VAR\">createButton</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_createButton\"><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">Check multiple files</field></shadow></value></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">createButton</field></block></value><next><block type=\"variables_set\"><field name=\"VAR\">count</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_createTextBlock\"><mutation xmlns=\"http://www.w3.org/1999/xhtml\" _expanded=\"0\" _input_init=\"false\"></mutation></block></value><next><block type=\"ScreenItem_Layout_add\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">mainLayout</field></block></value><value name=\"item\"><block type=\"variables_get\"><field name=\"VAR\">count</field></block></value><next><block type=\"ScreenItem_ScreenItem_onClick\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">createButton</field></block></value><statement name=\"HANDLER\"><block type=\"variables_set\"><field name=\"VAR\">gettingFile</field><value name=\"VALUE\"><shadow type=\"math_number\"><field name=\"NUM\">0</field></shadow><block type=\"Control_FileInput_getFiles\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">fileInput</field></block></value></block></value><next><block type=\"controls_if\"><mutation else=\"1\"/><value name=\"IF0\"><shadow type=\"logic_boolean\"><field name=\"BOOL\">TRUE</field></shadow><block type=\"Control_FileInput_isMultiple\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">fileInput</field></block></value></block></value><statement name=\"DO0\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">count</field></block></value><value name=\"content\"><block type=\"text_join\"><mutation items=\"3\"/><value name=\"ADD0\"><shadow type=\"text\"><field name=\"TEXT\">There are </field></shadow></value><value name=\"ADD1\"><shadow type=\"text\"><field name=\"TEXT\"/></shadow><block type=\"lists_length\"><value name=\"VALUE\"><block type=\"variables_get\"><field name=\"VAR\">gettingFile</field></block></value></block></value><value name=\"ADD2\"><shadow type=\"text\"><field name=\"TEXT\"> file(s).</field></shadow></value></block></value></block></statement><statement name=\"ELSE\"><block type=\"Control_TextBlock_setContent\"><value name=\"this\"><block type=\"variables_get\"><field name=\"VAR\">count</field></block></value><value name=\"content\"><shadow type=\"text\"><field name=\"TEXT\">Only one file is selected.</field></shadow></value></block></statement></block></next></block></statement></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block></xml>"}
				
			

當存在多個檔案時的輸出結果:

當只存在一個檔案時的輸出結果: