Thank you I have tried both; for the error block I have copied the if-return block and modified it
How would I let the user set the var name of the error block so I could then reference it in blockly
So far my error block is....
Blockly.Blocks['control_try_error'] = {
// Conditionally return value from a try catch.
init: function() {
this.setHelpUrl('
http://c2.com/cgi/wiki?GuardClause');
this.setColour(290);
this.appendValueInput('VALUE')
.appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
this.setInputsInline(true);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);
this.hasReturnValue_ = true;
},
mutationToDom: function() {
// Save whether this block has a return value.
var container = document.createElement('mutation');
container.setAttribute('value', Number(this.hasReturnValue_));
return container;
},
domToMutation: function(xmlElement) {
// Restore whether this block has a return value.
var value = xmlElement.getAttribute('value');
this.hasReturnValue_ = (value == 1);
if (!this.hasReturnValue_) {
this.removeInput('VALUE');
this.appendDummyInput('VALUE')
.appendTitle(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);
}
},
onchange: function() {
if (!this.workspace) {
// Block has been deleted.
return;
}
var legal = false;
// Is the block nested in a procedure?
var block = this;
block = block.getSurroundParent();
if (block.type == 'sds_try' ) {
this.removeInput('VALUE');
this.appendValueInput('VALUE')
.appendTitle("Error Value");
this.hasReturnValue_ = true;
this.setWarningText(null);
} else {
this.setWarningText("This block must be contained within a try catch");
}
}
};