I'm trying to get a script to work that is not in the JavaScripts folder.
When I search for a way to do that it says to use the
Code: Select all
import {} from "path"
App:Init:1: SyntaxError: import declarations may only appear at top level of a module
import CalculateStempel from "./Pathfile/PDFCalculatieMain.js"
I tried the
Code: Select all
import("path").then("do this")
This is the code I have in the JavaScripts folder, I copied part of the hatch tool and changed some things.
Code: Select all
var iconSet_hatchTool = { hatch:
iconStream:function(val){let data=this[val];
return {count:0, width:20, height:20, read:function(nBytes){return data.slice(this.count,this.count+=2*nBytes)}}}
};
// This adds a button to the Add-on Tools toolbar
app.addToolButton( {
cName: "CalculationTool",
cLabel: "Calculatie",
oIcon: iconSet_hatchTool.iconStream("hatch"),
cTooltext: "Calculeer stempels",
cExec: "getCalCode(this)" }
);
// This adds a menu item
app.addMenuItem( {
cName: "Calculation",
cUser: "Calculatie…",
oIcon: iconSet_hatchTool.iconStream("hatch"),
cParent: "Comments",
cExec: "getCalCode(this)" }
);
function getCalCode(t){
import("path").then(CalculateStempel(t));
console.println(CalculateStempel + " defined")
console.println("works")
}
Code: Select all
export function CalculateStempel(t){}
So my question is if it's possible to run a function that isn't in the JavaScripts folder?
Kind regards,
Berjan