Is there a way to select projects by position in searches?

Hello all,

I am trying to figure out a way to select projects by their position.

If I search using:

project [0]

…then I get the first project.

If I search using:

project [1]

…then I get the second project, and so on. This makes sense to me.

However, if I search for:

project [0] or [1]

…then I get nothing.

Am I on the wrong track using slices? Ideas?

My understanding of the slice indexes is that they express subsets of a search result.

For stretches of adjacent peers returned by searches like project or //project, you can write things like:

//project[2:5]

(which would yield up to three consecutive peer projects)

For non-consecutive peers, you will (I think) need to write distinct slices into multiple search sets, for example:

//project[2] union //project[6]

or

project[2] union project[6]
2 Likes

or, of course, you can harvest your search as a JS array, and multiply slice that:

(() => {
    'use strict';

    const
        xs = Application('TaskPaper')
        .documents.at(0).evaluate({
            script: '' + (
                e => e.outline.evaluateItemPath('project')
                .map(x => x.bodyString)
            ),
        });

    return [xs[0], xs[3]].join('\n');
})();
1 Like

Great ideas—you’ve given me some fine insights. Thank you @complexpoint!