Tree QuickStart Tutorial: Create a new Tree called `tree' ---------------------------- Tree clone tree The root node --------------- The Tree will already have a root node defined, which has the path `/' tree node / asText The Tree recognises a form of syntactic sugar, whereby you can send a message to a node just by giving its path, so the previous is equivalent to saying: tree / asText Now, let's work some more with the root node: tree / myPath tree / description: this is the root node of \"tree\" tree / editMethod helloWorld tree / asText tree / helloWorld # You created this method for the root node :) Create some more nodes ------------------- tree makeNode /animal/mammal/sheep tree makeNode /vegitable tree makeNode /mineral/rock you can also clone an existing Offsider, like so: tree makeNode /qr QueueReader Each node understands paths ------------------------- tree /animal node mammal myPath Each node understands syntactic sugar too.. ----------------- tree /animal mammal myPath tree / animal mammal/sheep myPath tree / animal mammal .. .. mineral/rock myPath tree / animal mammal /mineral/rock myPath Notice the last example. Nodes understand absolute paths as well as relative ones. The current path ----------------- The tree has a concept of the current path (like cwd or pwd in Unix). tree currentPath This starts out as "/", so in many of the previous examples, you could leave out the initial "/": tree animal mammal myPath Notice that the Tree's idea of a relative path is different to that of a node. For a node it is always relative to itself. For the Tree, it is relative to the currentPath. You can change the current path by using "cd": tree cd animal tree currentPath tree . myPath tree makeNode mammal/horse tree mammal/horse myPath You need to understand that because the Tree is an Offsider, the value of current path will remain the same until it gets changed again. This means that even if you log off, or the machine gets rebooted, the value will remain the same. You also need to understand that the value of currentPath will effect all users, and all processes that access that particular Tree. For these reasons, it is not as useful as the current working directory in Unix. tree cd / Listing the children of a node ------------ tree / ls tree ls / tree . ls tree ls . tree vegitable ls tree /animal ls mammal tree /vegitable ls .. tree ls /vegitable tree animal mammal ls sheep Do you understand why you can put "ls" in different places like that? It is because both the Tree and all of its nodes understand what "ls" means. Walking the tree ------------- You can walk through the tree, visiting all nodes and passing a message to each node in turn. tree . fastWalk myPath "fastWalk" is a method that nodes implement. It takes a message, and then sends that message to each node it visits. tree animal fastWalk ls .. You can do a "depth first" walk like this: tree . fastWalk depthFirst myPath Finally, you can remove nodes. ----------------- tree removeNode animal/mammal/sheep You can also remove a node, and all its children: tree forceRemoveNode mineral tree ls tree . fastWalk myPath Summary --------- Tree is still under development, and there are some useful methods that are still not implemented. It seems slower than other Offsider technologies (for example Weave), and there may be some scope for optimising critical methods for speed. cheers, Glen.