array set
This commit is contained in:
parent
d32e4125da
commit
5152fa6fee
2 changed files with 30 additions and 0 deletions
|
|
@ -79,6 +79,7 @@
|
|||
<block type="json_tostring" />
|
||||
<sep gap="64"></sep>
|
||||
<block type="json_arrayinsert" />
|
||||
<block type="json_arrayset" />
|
||||
<sep gap="48"></sep>
|
||||
<block type="json_arrayget" />
|
||||
<block type="json_arraylength" />
|
||||
|
|
|
|||
|
|
@ -82,6 +82,35 @@ function register() {
|
|||
return [`(${X || "[]"}.push(${Y || '""'}))`, javascriptGenerator.ORDER_ATOMIC];
|
||||
})
|
||||
|
||||
// set
|
||||
registerBlock(`${categoryPrefix}arrayset`, {
|
||||
message0: 'set %1 to %2 in %3',
|
||||
args0: [
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "X",
|
||||
"check": "Number"
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "Y",
|
||||
},
|
||||
{
|
||||
"type": "input_value",
|
||||
"name": "Z",
|
||||
"check": "JSONArray"
|
||||
},
|
||||
],
|
||||
output: "JSONArray",
|
||||
inputsInline: true,
|
||||
colour: categoryColor
|
||||
}, (block) => {
|
||||
const X = javascriptGenerator.valueToCode(block, 'X', javascriptGenerator.ORDER_ATOMIC);
|
||||
const Y = javascriptGenerator.valueToCode(block, 'Y', javascriptGenerator.ORDER_ATOMIC);
|
||||
const Z = javascriptGenerator.valueToCode(block, 'Z', javascriptGenerator.ORDER_ATOMIC);
|
||||
return [`(() => { var z = ${Z}; z[${X}] = ${Y}; return z })()`, javascriptGenerator.ORDER_ATOMIC];
|
||||
})
|
||||
|
||||
// get
|
||||
registerBlock(`${categoryPrefix}arrayget`, {
|
||||
message0: 'get %1 from array %2',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue