On Mon, Sep 21, Pro2020 at 7:21 AM '
info.sim...@googlemail.com' via
Notecase Pro <
noteca...@googlegroups.com> wrote:
>
> Hi
>
> I think I found a solution for filtering notes - root notes and all their childs only for now. The idea is to
>
> create a root note for the filter - the "filter note"
> search all existing root notes for the filter criteria
> create a clone of the matching root node with all child notes underneath the "filter note"
> hoist the "filter note"
I think that should be hoist the "filter note" *clone,* yes?
> this should yield exactly what I am looking for - in theory ;-) - a filtered tree structure whereby any edit will be reflected in the original note
>
> Curious how tricky it will be to code the stuff...
This would be easier to code if the goal was to clone the filter note
and all descendants of it, rather than just the children, which I
suspect is your longer term goal. Under the Notes Menu's Current Note
submenu, there is an action, "Insert Branch Clone," that can be
invoked programmatically. This action clones the entire branch.
preserving the hierarchy in the clones. To use this action, see Help
file > Automation, Scripts and Plugins > Scripting NoteCase Pro >
Scriptable Program Commands > Application Commands >
Nc_App_Action_Execute. The short action name you'd use is
"tree_clone_branch".
Unfortunately, there is no return from that action that would give you
the note ID for the cloned root note to hoist. One way to fetch the
note ID might be (untested) before cloning the branch, walk the tree
to identify the note ID of the last descendant of that root note. See
Help file > Automation, Scripts and Plugins > Scripting NoteCase Pro >
Code Snippets and Tips > Traversing Trees > Walking Down a Tree.
Fetch that note's recursive index using
Nc_Note_RecursiveIdx_GetByID(). Then navigate to the next note, which
is the clone root note, using Nc_Note_ID_GetByIdx(). (Add 1 to the
last descendant's recursive Idx to identify the clone root note.)
There are other ways you could get to the cloned root note. E.g., get
lists of all root note IDs before and after the clone branch is
created then look for the note ID in the second list that does not
exist in the first.
If you do want only the filter note's children to be cloned, let me
know and I'll give some thought to that problem.
Hope this helps.