In continuation of the topic
DataviewJs - Code reuse: common place for scripts
The solution listed there works only on PC, not on Mobile (Android). The path to the file is correct, but the DataviewJs script cannot find the file with the script.
Minimal Working Example:
```dataviewjs
let utilPath = app.vault.adapter.basePath + "/myscripts/myDataviewUtils.js"
function checkFileExistsSync(filepath){
let flag = true;
try{
if (fs.existsSync(utilPath)) {
//file exists
}
}catch(e){
flag = false;
}
return flag;
}
dv.paragraph("checkFileExistsSync: " + checkFileExistsSync(utilPath) + "<br>")
dv.paragraph("---------------------")
var myUtils = require(utilPath);
dv.paragraph("utilPath: " + utilPath)
dv.paragraph(myUtils.f1())
File 'myDataviewUtils.js':
export function f1() {
console.log(“Hello from f1”);
return “Hello from f1”
}
Does anyone know how I can call external DataviewJS functions?
I need the functions in many places and am currently copying all the code back and forth. The goal is to only specify the function call. Changes would then automatically affect all files.