A recursing function. Figure out the section name only when actually needed.
Code
function fAsk(iName){
if($IsTop(iName)){
return "";
};
if($IsTop(parent(iName))){
return $SiblingOrder;
}
return fAsk($Path(parent(iName)))+"."+$SiblingOrder;
};
Logic
- If the top, $IsTop should be
true
- If parent is the top, return $SiblingOrder
- Otherwise,
- ask the parent for their name,
- and then add "." and own $SiblingOrder.
Pros and Cons
- GOOD:
- Only computes the section numbers when needed
- Recursion is elegant
- BAD:
- Recursion can be tricky