maphew

Node ID's

August 22, 2019

Leo docs describe Global Node Index (gnx) as giving each node a unique, immutable identity.

1. How do you find the gnx identity of a node?

Using p.v.gnx (or p.v.fileIndex it used to be old name of this attribute).

2. Once you know the gnx of a node, can a script be directed to read the data in that node?

If you have gnx and wish to know headline or body, you can get corresponding v node using:

v = c.fileCommands.gnxDict.get(gnx)

v.h is headline, v.b is body.

I get the impression gnx's are related to external files, or clones. Whereas I am looking for a simple way to identify a node and read it's data.

Yes in the external files gnxes are written inside sentinel comments. Without them written in the external files, clones would loose their clone-yness and become unrelated nodes.

From <https://groups.google.com/forum/#!topic/leo-editor/PYPWpsvSFQU>

v.gnx is a python property, which resolves to v.fileIndex, a real ivar.  Properties are much slower than ivars, but usually that doesn't matter.  It's best just to use the simpler property.  Leo uses v.fileIndex during startup because its faster.  When in doubt, use v.gnx, not v.fileIndex.

From <https://groups.google.com/forum/#!topic/leo-editor/PYPWpsvSFQU>