Fix JS and PHP list/text blocks.

The length and is_empty blocks can take either text or lists.
This commit is contained in:
Neil Fraser
2015-10-03 07:45:16 -07:00
parent ac9de0d915
commit c413fa1678
10 changed files with 43 additions and 23 deletions

View File

@@ -56,14 +56,14 @@ Blockly.Python['lists_repeat'] = function(block) {
};
Blockly.Python['lists_length'] = function(block) {
// List length.
// String or array length.
var argument0 = Blockly.Python.valueToCode(block, 'VALUE',
Blockly.Python.ORDER_NONE) || '[]';
return ['len(' + argument0 + ')', Blockly.Python.ORDER_FUNCTION_CALL];
};
Blockly.Python['lists_isEmpty'] = function(block) {
// Is the list empty?
// Is the string null or array empty?
var argument0 = Blockly.Python.valueToCode(block, 'VALUE',
Blockly.Python.ORDER_NONE) || '[]';
var code = 'not len(' + argument0 + ')';