Thank you very much!
I do not have any experience with scripts whatsoever, will have to figure out how this works.
I found the suggestions at http://support.foldingtext.com/t/how-to-install-a-script/75.
Following the instructions to try a script, I copied the script into the Apple script editor, but got a syntax error at the opening bracket “(” in the first line of the script, “function run() {”.
My lack of experience is probably the cause of forgetting some crucial steps in making script work.
(If the script works, I plan to install it (will then have to figure out how to save it in “script” format)).
Thank you,
Paul
Trying out the script seemed to work, since it generated (recognizable) output below the script-editing field, though not yet in a useful format, at first sight at least, form looking at the little screen in the script editor. Next, I installed the script by saving the script into the indicated folder.
When I executed the script, nothing seemed to happen. I figured out that the output is written to the clipboard, and can be “written” to an empty FT document by pressing CMD-V. Perhaps this instruction could be added somewhere on the forum.
Good point – here’s a version which creates a fresh document containing the sorted due list.
function run() {
var blnDebug = 0;
// create new doc from sorted list ?
var blnMakeDoc = 1; //(0 if not)
function fnFT(editor, opt) {
// EVALUATE THE NODE PATH //@due TO HARVEST MATCHES
var oTree = editor.tree(),
lstNodes = oTree.evaluateNodePath('//@due'),
lstDue=[], strList;
// BUILD A LIST OF DATES FOLLOWED BY TEXT
lstNodes.forEach(function (oNode) {
lstDue.push(oNode.tag('due') + '\t' + oNode.text());
});
// SORT AND CONVERT TO STRING
strList = lstDue.sort().join('\n');
// PLACE IN CLIPBOARD
Pasteboard.writeString(
strList
);
return strList;
}
var appFT = Application("FoldingText"),
docsFT=appFT.documents(),
oDoc = docsFT.length ? docsFT[0] : null,
fnProcess, varResult, docResult;
if (!oDoc) return null;
fnProcess = (blnDebug ? oDoc.debug : oDoc.evaluate);
varResult = fnProcess({
script: fnFT.toString(),
withOptions: {}
});
// If blnMakeDoc (at the top of this script) = 1
// then create a new document to contain the result
if (blnMakeDoc && varResult) {
docResult = appFT.Document().make();
docResult.textContents = "### Due\n" + varResult;
}
return varResult;
}
Hi,
I found this script very useful. I was wondering if is it possible to modify the script in the way to extract all ‘due’ tags from multiple files at one run. I use one index file that contains links to all my projects files. Currently, I have over 20 files, each with a separate todo list. Extracting task list into one ‘due’ file would help to review all todos.
Maybe there is another way of doing that without the due date script?
Thanks
Marek