Hi Bart :D
There are two options, and they depend on one question: Is the getResult() function defined by you, the developer? Or is it defined by the person using Blockly to write code?
If it is defined by you, then you can just define a stringified version of that function and prepend it to your generated code. For example:
```
var prefix = 'function getResult() {\n'
+ ' return "Hello World";\n' +
'}\n';
var code = Blockly.JavaScript.workspaceToCode(myWorkspace);
code = prefix + code;
This makes it so that your function only exists once. It is also basically how the procedure blocks work, except for them the logic exists inside of Blockly, while for you it exists inside your application.
If it is defined by the user, then procedures are exactly what you want =) You can just
add the procedure category to your toolbox, and they should work out of the box.
I hope that helps! If you have any further questions please reply!
--Beka