Hi
Consider 2 function nodes, A and B.
Is it possible to reference a function written in A from node B?
I've tried searching for "referencing functions" and "scope of functions in function node".
Example:
[
{
"id": "95c7830baecc1f89",
"type": "function",
"z": "558ac96c.c926d8",
"name": "A: Spreadsheet numbering functions",
"func": "//Use these to convert to and from spreadsheet column numbering\n//https://codereview.stackexchange.com/questions/16124/implement-numbering-scheme-like-a-b-c-aa-ab-aaa-similar-to-converting?rq=1\nfunction convertToNumberingScheme(number) {\n var letters = \"\";\n const charCodeOfA = \"A\".charCodeAt(0);\n\n do {\n number -= 1;\n letters = String.fromCharCode(charCodeOfA + (number % 26)) + letters;\n number = (number / 26) >> 0; // quick `floor`\n } while(number > 0);\n\n return letters;\n}\n\n//https://stackoverflow.com/questions/9905533/convert-excel-column-alphabet-e-g-aa-to-number-e-g-25\nfunction lettersToNumber(letters){\n return letters.split('').reduce((r, a) => r * 26 + parseInt(a, 36) - 9, 0);\n}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2490,
"y": 1060,
"wires": [
[]
]
},
{
"id": "3ad0b91b0c6272be",
"type": "inject",
"z": "558ac96c.c926d8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 2360,
"y": 1120,
"wires": [
[
"55717a09a50eba9a"
]
]
},
{
"id": "1b48414330830eff",
"type": "debug",
"z": "558ac96c.c926d8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 2630,
"y": 1120,
"wires": []
},
{
"id": "55717a09a50eba9a",
"type": "function",
"z": "558ac96c.c926d8",
"name": "B: Test",
"func": "const radix = 26;\nvar radixTest = [];\n\nfor(var i=1; i <182; i++){\n radixTest[i] = {};\n radixTest[i].string = i.toString(radix);\n radixTest[i].num = parseInt(radixTest[i].string, radix);\n radixTest[i].convertToNumberingScheme = convertToNumberingScheme(i);\n radixTest[i].lettersToNumber = lettersToNumber(radixTest[i].convertToNumberingScheme)\n}\n\nreturn {radixTest:radixTest};\n\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 2500,
"y": 1120,
"wires": [
[
"1b48414330830eff"
]
]
}
]
I feel like I've seen this in some node's example, but I cannot remember which one.
Thanks,
Ashfaak