I’m currently working on creating blocks for the wizard, but I’ve run into an issue. When creating the blocks, I can’t access the variables of a record that’s stored in an array. How can I implement this? Right now, the only option I see is using a dropdown, but I’d rather avoid that because an operator should be able to create new variables instead of being limited to selecting existing ones.
PERS multidata mdA7{3}:= [
[10,0,0,0],
[4,0,0,6],
[0,4,10,6]
];
RECORD multidata
num offsetVertical;
num offsetHorizontal;
num offsetAngle;
num offsetStartEnd;
ENDRECORD
{
“blockType”: “WeldMoveLinear_*2”,
“instructionName”: “WeldMoveLinear”,
“blockDefinition”: {
“initJson”: {
“type”: “WeldMoveLinear_*2”,
“message0”: “Weld linear to %1 using %2 and %3 %4”,
“args0”: [
{
“type”: “field_coblox_variable”,
“name”: “ToPoint”,
“varType”: “Location”
},
{
“type”: “field_coblox_variable”,
“name”: “wiSeamdata”,
“varType”: “Seamdata”,
“options”: “”
},
{
“type”: “field_coblox_variable”,
“name”: “wiWelddata”,
“varType”: “Welddata”,
“options”: “”
},
{
“type”: “field_plusminus”,
“name”: “HAS_OPTIONAL”
}
],
“mutator”: “optional_block_mutator”,
“inputsInline”: true,
“previousStatement”: null,
“nextStatement”: null,
“colour”: “#5c29cc”,
“tooltip”: “”,
“helpUrl”: “”,
“blockinformation”: {
“description”: “”,
“webappname”: “”,
“additionalinformation”: “”
},
“bindIf”: false,
“expandOptParams”: false
},
“selectedDPItem”: {
“wiSeamdata”: “”,
“wiWelddata”: “”
},
“colour”: “#5c29cc”
},
“optBlockDefinition”: {
“initJson”: {
“type”: “WeldMoveLinear_*2_#opt”,
“message0”: "\\wmWeaveData := %1 \\wmMultiData := %2 ",
“args0”: [
{
“type”: “field_coblox_variable”,
“name”: “wmWeaveData”,
“varType”: “Weavedata”,
“options”: “disable”
},
{
“type”: “field_coblox_variable”,
“name”: “wmMultiData”,
“varType”: “MultiData”,
“options”: “disable”
}
],
“output”: “Optional”,
“colour”: “#5c29cc”,
“tooltip”: “”,
“helpUrl”: “”
},
“colour”: “#5c29cc”
},
“blockGenerator”: “function(block) {\n var ToPoint = block.getFieldValue(‘ToPoint’);\n var wiSeamdata = block.getFieldValue(‘wiSeamdata’);\n var wiWelddata = block.getFieldValue(‘wiWelddata’);\nif (block.getInputTargetBlock(‘OPTIONAL’) != null) {\n var optional = {}\n for (const iterator of block.getInputTargetBlock(‘OPTIONAL’).inputList[0].fieldRow) {\n if (iterator instanceof Blockly.FieldLabel) continue\n optional[iterator.name] = { name: iterator.name, value: iterator.value_ }\n }\n}\n let instrName = block.type.split(\”_*\“);\n var _res = ToPoint+‘,’+wiSeamdata+‘,’+wiWelddata+‘,’+(optional && optional.wmWeaveData && optional.wmWeaveData.value != ‘disable’? (optional.wmWeaveData.value == ‘enable’?(‘\\\\’ + optional.wmWeaveData.name+‘,’):(‘\\\\’ + optional.wmWeaveData.name + ‘:=’ + optional.wmWeaveData.value+‘,’)): ‘’)+(optional && optional.wmMultiData && optional.wmMultiData.value != ‘disable’? (optional.wmMultiData.value == ‘enable’?(‘\\\\’ + optional.wmMultiData.name+‘,’):(‘\\\\’ + optional.wmMultiData.name + ‘:=’ + optional.wmMultiData.value+‘,’)): ‘’);\n _res = (typeof _res).toLowerCase()==‘string’?_res.substr(-1)== ‘,’? _res.slice(0,-1):_res:_res;\n var code = \“ID:\” + block.id + \” \" + instrName[0]+ \" \" + _res + \“;\\n\”;\n return code;\n}",
“sortedFields”: [
{
“type”: “shown”,
“fieldName”: “ToPoint”
},
{
“type”: “shown”,
“fieldName”: “wiSeamdata”
},
{
“type”: “shown”,
“fieldName”: “wiWelddata”
},
{
“type”: “shown”,
“fieldName”: “wmWeaveData”
},
{
“type”: “shown”,
“fieldName”: “wmMultiData”
}
],
“inputBCArray”: [
{
“text”: "Weld linear to ",
“type”: 0,
“label”: “field_static”
},
{
“text”: “ToPoint”,
“type”: 1,
“label”: “field_location”
},
{
“text”: " using ",
“type”: 0,
“label”: “field_static”
},
{
“text”: “wiSeamdata”,
“type”: 1,
“label”: “field_dropdown_custom”
},
{
“text”: " and ",
“type”: 0,
“label”: “field_static”
},
{
“text”: “wiWelddata”,
“type”: 1,
“label”: “field_dropdown_custom”
},
{
“text”: " ",
“type”: 0,
“label”: “field_static”
}
],
“inputOptBCArray”: [
{
“text”: "\\wmWeaveData := ",
“type”: 0,
“label”: “field_static”
},
{
“text”: “Weavedata”,
“type”: 1,
“label”: “field_dropdown_custom”
},
{
“text”: " \\wmMultiData := ",
“type”: 0,
“label”: “field_static”
},
{
“text”: “wmMultiData”,
“type”: 1,
“label”: “field_dropdown_custom”
},
{
“text”: " ",
“type”: 0,
“label”: “field_static”
}
],
“addedFields”: [
{
“text”: “ToPoint”,
“label”: “field_location”,
“defaultValue”: “somewhere”,
“bOptional”: false
},
{
“text”: “wiSeamdata”,
“label”: “field_dropdown_custom”,
“defaultValue”: “Seamdata”,
“bOptional”: false
},
{
“text”: “wiWelddata”,
“label”: “field_dropdown_custom”,
“defaultValue”: “Welddata”,
“bOptional”: false
}
],
“addedOptFields”: [
{
“text”: “Weavedata”,
“label”: “field_dropdown_custom”,
“defaultValue”: “Weavedata”,
“bOptional”: true
},
{
“text”: “wmMultiData”,
“label”: “field_dropdown_custom”,
“defaultValue”: “Multidata”,
“bOptional”: true
}
],
“hasOptionalBlock”: true,
“defaultLang”: “”,
“allBCofLangs”: {}
},