@Craig I saw your helpful comments over here: Can I import dataviewjs from other file? - #5 by Craig
I feel like I’m almost getting it, but not quite.
I think I just don’t understand the documentation well enough.
I have a file called scriptbits.js in a folder (in my vault) called Script, so I’ve tried putting in await dv.view("Script/scriptbits") in my attempted code.
This is what my code looks like:
let BookCount = (dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook").length);
await dv.view ("Script/scriptbits/")
dv.paragraph("# I've read " + (pagesum) + " pages.")
And this is what’s currently in scriptbits.js:
let pagesum = 0;
for(let i = 0; i < dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook").length; i++) {
if(dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook")[i].Length) {
pagesum += dv.pages('"Book Log/2022"').where(p => p.Medium == "Book" || p.Medium == "eBook")[i].Length;
}
}
But then I still get the error pagesum not defined. What am I missing?
Thanks! (@holroy )