Here’s something that was indirectly supported by BARfly, but only recently supported by the underlying BAR engine with version 1.3.
A BAR Navigational String, or BNS, is a “path” string used to locate BAR nodes in the tree control using absolute or relative positions. I’ve actually modeled it off the UNIX/DOS/Windows method of accessing files and directories through pathnames.
For example, if you want to access a file, called “thisfile.txt”, located inside the “thisdir” directory, which is itself nested inside another “outerdir” directory, the pathname would look like this:
“outerdir/thisdir/thisfile.txt”
Similarly, in BAR, you can access a node several levels “deep” in the tree by referring to children with names or numbers. Each token, separated by forward or backward slashes, represents one navigation. Take the following example:
“outernode/thisnode/62″
This BNS says, execute Child(“outernode”), followed by Child(“thisnode”), followed by Child(62).
Neat, isn’t it? You can compress many navigation operations into only one function argument. The best part is that almost nothing new needs to be learned. The philosophy behind node navigation is totally synonymous with file system navigation!
There are other parallels, too. A summary of how BNS compares with file system pathnames:
“/”
File system: Go to root directory
BNS: Execute Toplevel()
“a/b/c”
File system: Go to subdirectory “a,” then subdirectory “b,” then refer to “c” (can be either file or directory)
BNS: Execute Child(“a”), then Child(“b”), then Child(“c”)
“../otherdir”
File system: Go up to parent directory, then down again to subdirectory “otherdir”
BNS: Execute Parent(), then Child(“otherdir”)
“.”
File system: Refer to same directory
BNS: No navigation
Beyond this point, BNS and file system pathnames diverge. For example, BNS does not currently support wildcards, and BNS is capable of other operations that file systems cannot perform. Some additional BNS syntax:
“44″
Navigate to zero-based child (45th child of current)
“>>”
Navigate to next 2 siblings (call Next(1) twice)
“<<<"
Navigate to previous 3 siblings (call Previous(1) three times)
“+50″
Navigate 50 siblings forward (call Next(50))
“-30″
Navigate 30 siblings backward (call Previous(30))
“^13″
Search forward for construct UID of 13 (call Search_Forward(13))
“^container7″
Search forward for construct or variable name of “container7″ (call Search_Forward(“container7″))
Eventually, BNS will support even more radical navigation possibilities, like wildcards, named bookmarks, and maybe even special subroutine-based navigations.
Ultimately, my goal is to merge BNS with file system logic. Think about what you could do if your ability to access information is not confined to just the file system or even the file contents: you could “collect” or “populate” information inside a file from the command line of an application! Too bad no operating systems let you dive this “deep” right now.
Pop quiz: what does this BNS do?
“/1078/mychild/./nextchild/../+8/otherchild/-1/32/>>>>>/^1″
Answer:
Toplevel(); Child(1078); Child(“mychild”); ; Child(“nextchild”); Parent(); Next(8); Child(“otherchild”); Previous(); Child(32); Next(5); Search_Forward(1);